모듈: Mongoid::Contextual::Atomic
- 다음에 정의됨:
- lib/mongoid/contextual/atomic.rb
개요
Mongoid::Criteria에 포함된 Mixin 모듈은 MongoDB의 업데이트 연산자($ 설정하다 , $pull, $inc 등)에 대한 직접 메서드 인터페이스를 제공합니다. 이러한 연산자는 로드 없이 기준 범위 내 데이터베이스 의 모든 문서를 업데이트 데 적용할 수 있습니다. 각 문서 Mongoid의 메모리에 저장합니다.
인스턴스 메서드 요약 접기
-
#add_each_to_set(추가) ⇒ nil
일치하는 문서에 대해 원자적 $addToSet/$each를 수행합니다.
-
#add_to_set(adds) ⇒ nil
일치하는 문서에서 원자적 $addToSet를 실행합니다.
-
#bit(bits) ⇒ nil
일치하는 문서에 대해 원자적 $bit 작업을 수행합니다.
-
#inc(incs) ⇒ nil
일치하는 문서에 대해 원자적 $inc 작업을 수행합니다.
-
#mul(인자) ⇒ nil
일치하는 문서에 대해 원자적 $mul 연산을 수행합니다.
-
#pop(pops) ⇒ nil
일치하는 문서에 대해 원자적 $pop 작업을 수행합니다.
-
#pull(pull) ⇒ nil
일치하는 문서에 대해 원자적 $pull 작업을 수행합니다.
-
#pull_all(pull) ⇒ nil
일치하는 문서에 대해 원자적 $pullAll 작업을 수행합니다.
-
#push(pushes) ⇒ nil
일치하는 문서에 대해 원자적 $push 작업을 수행합니다.
-
#push_all(푸시) ⇒ nil
일치하는 문서에 대해 원자적 $push/$each 작업을 수행합니다.
-
#rename(renames) ⇒ nil
일치하는 문서에서 필드의 원자적 $rename을 수행합니다.
-
#set(sets) ⇒ nil
일치하는 문서에서 원자적 $set의 필드를 수행합니다.
-
#set_max(fields) ⇒ nil (동의어: #camp_lower_bound)
지정된 필드 에 대해 원자적 $max 업데이트 작업을 수행합니다.
-
#set_min(fields) ⇒ nil (동의어: #camp_upper_bound)
지정된 필드 에 대해 원자적 $min 업데이트 작업을 수행합니다.
-
#unset(*unsets) ⇒ nil
일치하는 문서에서 필드의 원자적 $unset을 수행합니다.
인스턴스 메서드 세부 정보
#add_each_to_set(추가) ⇒ nil
일치하는 문서에 대해 원자적 $addToSet/$each를 수행합니다.
31 32 33 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 31 def add_each_to_set(추가합니다.) 보기.update_many('$addToSet' => collection_each_operations(추가합니다.)) end |
#add_to_set(adds) ⇒ nil
일치하는 문서에서 원자적 $addToSet를 실행합니다.
19 20 21 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 19 def add_to_set(추가합니다.) 보기.update_many('$addToSet' => collection_operations(추가합니다.)) end |
#bit(bits) ⇒ nil
일치하는 문서에 대해 원자적 $bit 작업을 수행합니다.
43 44 45 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 43 def 비트(비트) 보기.update_many('$bit' => collection_operations(비트)) end |
#inc(incs) ⇒ nil
일치하는 문서에 대해 원자적 $inc 작업을 수행합니다.
55 56 57 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 55 def Inc(incs) 보기.update_many(' $inc ' => collection_operations(incs)) end |
#mul(인자) ⇒ nil
일치하는 문서에 대해 원자적 $mul 연산을 수행합니다.
67 68 69 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 67 def mul(요인) 보기.update_many('$mul' => collection_operations(요인)) end |
#팝업(pops) ⇒ nil
일치하는 문서에 대해 원자적 $pop 작업을 수행합니다.
82 83 84 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 82 def 팝(팝) 보기.update_many('$pop' => collection_operations(팝)) end |
#pull(pull) ⇒ nil
표현식 풀링은 아직 지원되지 않습니다.
일치하는 문서에 대해 원자적 $pull 작업을 수행합니다.
96 97 98 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 96 def pull(pulls) 보기.update_many('$pull' => collection_operations(pulls)) end |
#pull_all(pulls) ⇒ nil
일치하는 문서에 대해 원자적 $pullAll 작업을 수행합니다.
108 109 110 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 108 def pull_all(pulls) 보기.update_many('$pullAll' => collection_operations(pulls)) end |
#push(푸시) ⇒ nil
일치하는 문서에 대해 원자적 $push 작업을 수행합니다.
120 121 122 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 120 def push(푸시) 보기.update_many('$push' => collection_operations(푸시)) end |
#push_all(푸시) ⇒ nil
일치하는 문서에 대해 원자적 $push/$each 작업을 수행합니다.
132 133 134 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 132 def push_all(푸시) 보기.update_many('$push' => collection_each_operations(푸시)) end |
#rename(renames) ⇒ nil
일치하는 문서에서 필드의 원자적 $rename을 수행합니다.
144 145 146 147 148 149 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 144 def 이름 변경(rename) 연산 = rename.each_with_object({}) do |(old_name, new_name), ops| ops[old_name] = new_name.to_s end 보기.update_many('$rename' => collection_operations(연산)) end |
#set(sets) ⇒ nil
일치하는 문서에서 원자적 $set의 필드를 수행합니다.
159 160 161 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 159 def 세트(집합 (Sets)) 보기.update_many('$set' => collection_operations(집합 (Sets))) end |
#set_max(fields) ⇒ nil ~ 라고도 함: camp_lower_bound
Mongoid::Contextual::Aggregable::Mongo#max가 있기 때문에 이 메서드의 이름을 #max로 지정할 수 없으며, 이는 다른 유사한 메서드에서 수행하는 MongoDB 작업의 이름 지정 규칙을 위반합니다.
지정된 필드 에 대해 원자적 $max 업데이트 작업을 수행합니다. 각 필드 는 [current_value, 주어진 값]의 최대값으로 설정하다 됩니다. 이렇게 하면 각 필드 가 지정된 값보다 작지 않은지 확인하는 효과가 있습니다. 즉, 지정된 값은 해당 필드 의 유효 최소값 입니다.
219 220 221 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 219 def set_max(필드) 보기.update_many('$max' => collection_operations(필드)) end |
#set_min(fields) ⇒ nil ~ 라고도 함: camp_upper_bound
Mongoid::Contextual::Aggregable::Mongo#min이 있기 때문에 이 메서드의 이름을 #min으로 지정할 수 없으며, 따라서 이 메서드가 수행하는 MongoDB 작업에 따라 이름을 지정하는 관행을 깨는 것입니다.
지정된 필드 에 대해 원자적 $min 업데이트 작업을 수행합니다. 각 필드 는 [current_value, 주어진 값]의 최소값으로 설정하다 됩니다. 이렇게 하면 각 필드 가 지정된 값보다 크지 않은지 확인하는 효과가 있습니다. 즉, 지정된 값은 해당 필드 의 유효 최대 값입니다.
196 197 198 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 196 def set_min(필드) 보기.update_many('$min' => collection_operations(필드)) end |
#unset(*unsets) ⇒ nil
일치하는 문서에서 필드의 원자적 $unset을 수행합니다.
174 175 176 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 174 def Unset(*Unsets) 보기.update_many('$unset' => collection_unset_operations(Unsets)) end |