모듈: Mongoid::Positional
- 다음에 정의됨:
- lib/mongoid/positional.rb
개요
이 모듈은 업데이트 선택기를 취하고 적절한 경우 $ 위치 연산자 의 인덱스를 전환하는 역할을 합니다.
인스턴스 메서드 요약 접기
-
#위치 적으로(선택기, 연산, 처리됨 = {}) ⇒ 해시
제공된 선택기와 원자 조작을 수행하고 필요할 때 내장된 문서의 인덱스를 위치 연산자 로 바꿉니다.
인스턴스 메서드 세부 정보
#위치 적으로(선택기, 연산, 처리됨 = {}) ⇒ 해시
참고:
The only time we can accurately know when to use the positional operator is at the exact time we are going to persist something. So we can tell by the selector that we are sending if it is actually possible to use the positional operator at all. For example, if the selector is: { "_id" => 1 }, then we could not use the positional operator for updating embedded documents since there would never be a match - we base whether we can based on the number of levels deep the selector goes, and if the id values are not nil.
제공된 선택기와 원자 조작을 수행하고 필요할 때 내장된 문서의 인덱스를 위치 연산자 로 바꿉니다.
31 32 33 34 35 36 37 |
# 파일 'lib/mongoid/positional.rb', 줄 31 def 위치적으로(선택기, 연산, 처리됨 = {}) 반환 연산 만약 선택기.size == 1 || 선택기.values.어떤? { |val| val.nil? } 키 = 선택기.키.map { |m| m.sub('._id', '') } - [ '_id' ] 키 = 키.sort_by { |s| s.분량 * -1 } process_operations(키, 연산, 처리됨) end |