모듈: 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를 수행합니다.
34 35 36 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 34 def add_each_to_set(추가합니다.) 보기.update_many("$addToSet" => collection_each_operations(추가합니다.)) end |
#add_to_set(adds) ⇒ nil
일치하는 문서에서 원자적 $addToSet를 실행합니다.
22 23 24 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 22 def add_to_set(추가합니다.) 보기.update_many("$addToSet" => collection_operations(추가합니다.)) end |
#bit(bits) ⇒ nil
일치하는 문서에 대해 원자적 $bit 작업을 수행합니다.
46 47 48 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 46 def 비트(비트) 보기.update_many("$bit" => collection_operations(비트)) end |
#inc(incs) ⇒ nil
일치하는 문서에 대해 원자적 $inc 작업을 수행합니다.
58 59 60 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 58 def Inc(incs) 보기.update_many("$inc" => collection_operations(incs)) end |
#mul(인자) ⇒ nil
일치하는 문서에 대해 원자적 $mul 연산을 수행합니다.
70 71 72 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 70 def mul(요인) 보기.update_many("$mul" => collection_operations(요인)) end |
#팝업(pops) ⇒ nil
일치하는 문서에 대해 원자적 $pop 작업을 수행합니다.
85 86 87 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 85 def 팝(팝) 보기.update_many("$pop" => collection_operations(팝)) end |
#pull(pull) ⇒ nil
표현식 풀링은 아직 지원되지 않습니다.
일치하는 문서에 대해 원자적 $pull 작업을 수행합니다.
99 100 101 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 99 def pull(pulls) 보기.update_many("$pull" => collection_operations(pulls)) end |
#pull_all(pulls) ⇒ nil
일치하는 문서에 대해 원자적 $pullAll 작업을 수행합니다.
111 112 113 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 111 def pull_all(pulls) 보기.update_many("$pullAll" => collection_operations(pulls)) end |
#push(푸시) ⇒ nil
일치하는 문서에 대해 원자적 $push 작업을 수행합니다.
123 124 125 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 123 def push(푸시) 보기.update_many("$push" => collection_operations(푸시)) end |
#push_all(푸시) ⇒ nil
일치하는 문서에 대해 원자적 $push/$each 작업을 수행합니다.
135 136 137 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 135 def push_all(푸시) 보기.update_many("$push" => collection_each_operations(푸시)) end |
#rename(renames) ⇒ nil
일치하는 문서에서 필드의 원자적 $rename을 수행합니다.
147 148 149 150 151 152 153 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 147 def 이름 변경(rename) 연산 = rename.주입({}) do |ops, (old_name, new_name)| ops[old_name] = new_name.to_s ops end 보기.update_many("$rename" => collection_operations(연산)) end |
#set(sets) ⇒ nil
일치하는 문서에서 원자적 $set의 필드를 수행합니다.
163 164 165 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 163 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, 주어진 값]의 최대값으로 설정하다 됩니다. 이렇게 하면 각 필드 가 지정된 값보다 작지 않은지 확인하는 효과가 있습니다. 즉, 지정된 값은 해당 필드 의 유효 최소값 입니다.
223 224 225 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 223 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, 주어진 값]의 최소값으로 설정하다 됩니다. 이렇게 하면 각 필드 가 지정된 값보다 크지 않은지 확인하는 효과가 있습니다. 즉, 지정된 값은 해당 필드 의 유효 최대 값입니다.
200 201 202 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 200 def set_min(필드) 보기.update_many("$min" => collection_operations(필드)) end |
#unset(*unsets) ⇒ nil
일치하는 문서에서 필드의 원자적 $unset을 수행합니다.
178 179 180 |
# 파일 'lib/mongoid/contextual/atomic.rb', 줄 178 def Unset(*Unsets) 보기.update_many('$unset' => collection_unset_operations(Unsets)) end |