클래스: Mongo::Collection
- 상속:
-
객체
- 객체
- Mongo::Collection
- 확장자:
- 전달 가능
- 다음을 포함합니다.
- 헬퍼, QueryableEncryption, 재시도 가능
- 다음에 정의됨:
- lib/ Mongo/ 컬렉션.rb,
lib/
Mongo/
컬렉션/view.rb,
lib/ Mongo/ 컬렉션/helpers.rb,
lib/
Mongo/ 컬렉션/view/iterable.rb, lib/ Mongo/ 컬렉션/view/readable. rb, lib/
Mongo/ 컬렉션/view/writable.rb, lib/
Mongo/ 컬렉션/view/mutable.rb, lib/ Mongo/ 컬렉션/view/map_reduce.rb,
lib/ Mongo/ 컬렉션/view/ 집계.rb,
lib/ Mongo/ 컬렉션/view/explainable.rb,
lib/ Mongo/ 컬렉션/view/change_stream.rb, lib/ Mongo/ 컬렉션/queryable_encryption.rb,
lib/ Mongo/ 컬렉션/view/builder/map_reduce.rb,
lib/ Mongo/ 컬렉션/view/builder/ 집계.rb,
lib/ Mongo/ 컬렉션/view/ 집계/behavior.rb, lib/ Mongo/ 컬렉션/view/change_stream/retryable.rb
개요
데이터베이스 의 컬렉션 과 컬렉션에 직접 적용할 수 있는 작업을 나타냅니다.
네임스페이스 아래에 정의됨
모듈: 헬퍼, QueryableEncryption 클래스: 보기
상수 요약 접기
- CAPPED =
고정 사이즈 옵션.
'고정'- NS =
ns 필드 상수입니다.
'ns'- CHANGEABLE_OPTIONS =
#with 메서드를 통해 새 Collection 인스턴스 에서 업데이트할 수 있는 옵션입니다.
%i[읽기 read_concern 쓰기 write_concern].동결
- CREATE_COLLECTION_OPTIONS =
이 상수는 비공개 API의 일부입니다. 이 상수는 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.
옵션 맵을 사용하여 컬렉션 옵션을 변환합니다.
{ time_series: :timeseries, expire_after: :expireAfterSeconds, clustered_index: :clusteredIndex, change_stream_pre_and_post_images: :changeStreamPreAndPostImages, encryption_fields: :encryptedFields, validator: :validator, view_on: :viewOn }
QueryableEncryption에 포함된 상수
QueryableEncryption::QE2_MIN_WIRE_VERSION
인스턴스 속성 요약 접기
-
#database ⇒ Mongo::Database
읽기 전용
컬렉션 이 있는 데이터베이스 입니다.
-
#이름 ⇒ string
읽기 전용
컬렉션의 이름입니다.
-
옵션 #개 ⇒ 해시
읽기 전용
컬렉션 옵션.
인스턴스 메서드 요약 접기
-
#==(기타) ⇒ true | false
컬렉션 이 다른 객체 와 같은지 확인합니다.
-
#aggregate(파이프라인, options = {}) ⇒ View::Aggregation
컬렉션 에 대해 집계 을 수행합니다.
-
#bulk_write(요청, 옵션 = {}) ⇒ BulkWrite::Result
일괄 쓰기 (write) 작업을 배치 실행합니다.
-
#고정? ⇒ true | false
컬렉션 제한이 있나요?
-
#count(filter = nil, options = {}) ⇒ 정수
사용 중단
더 이상 사용되지 않습니다.
대신 #count_documents 또는 expected_document_count를 사용하세요. 그러나 #count_documents로 전환할 때는 다음 연산자를 대체해야 합니다.
* $where should be replaced with $expr * $near should be replaced with $geoWithin with $center * $nearSphere should be replaced with $geoWithin with $centerSphere -
#count_documents(filter = {}, options = {}) ⇒ 정수
쿼리 와 일치하는 문서 수를 가져옵니다.
-
#create(opts = {}) ⇒ 결과
데이터베이스 에 컬렉션 을 강제로 생성합니다.
-
#delete_many(필터하다 = nil, options = {}) ⇒ Result
컬렉션 에서 문서를 제거합니다.
-
#delete_one(필터하다 = nil, options = {}) ⇒ 결과
컬렉션 에서 문서 를 제거합니다.
-
#distinct(field_name, 필터하다 = nil, options = {}) ⇒ Array<Object>
특정 필드 에 대한 고유 값 목록을 가져옵니다.
-
#drop(opts = {}) ⇒ 결과
컬렉션을 제거합니다.
-
#추정 _문서_카운트 (옵션 = {}) ⇒ 정수
컬렉션 메타데이터 를 사용하여 컬렉션 내 문서 수의 추정치를 가져옵니다.
-
#find(filter = nil, options = {}) ⇒ CollectionView
컬렉션에서 문서를 찾습니다.
-
#find_one_and_delete(필터하다, options = {}) ⇒ BSON::Document?
findAndModify를 통해 데이터베이스에서 단일 문서를 찾아 삭제하고 원본 문서를 반환합니다.
-
#find_one_and_replace(필터하다, 교체 , 옵션 = {}) ⇒ BSON::Document
단일 문서 를 찾아 대체하고, 달리 지정되지 않는 한 원본 문서를 반환합니다.
-
#find_one_and_update(filter, update, options = {}) ⇒ BSON::Document
findAndModify를 통해 단일 문서 를 찾아 업데이트하고, 달리 지정되지 않는 한 원본 문서를 반환합니다.
-
#indexes(options = {}) ⇒ Index::View
이 컬렉션 의 모든 인덱스 보기를 가져옵니다.
-
#initialize(데이터베이스, name, options = {}) ⇒ Collection
생성자
새 컬렉션 을 인스턴스화합니다.
-
#insert_many(documents, options = {}) ⇒ Result
제공된 문서를 컬렉션에 삽입합니다.
-
#insert_one(문서, opts = {}) ⇒ Result
컬렉션에 단일 문서를 삽입합니다.
-
#검사 ⇒ string
컬렉션 에 대한 예쁜 인쇄된 string 검사를 가져옵니다.
-
#네임스페이스 ⇒ string
컬렉션 의 정규화된 네임스페이스 를 가져옵니다.
-
#operation_timeouts(opts = {}) ⇒ 해시
비공개
작업 수준에서 설정하다 Timeout_ms 값(있는 경우) 및/또는 컬렉션/ 데이터베이스/ 클라이언트 수준(있는 경우)에 설정하다 timeout_ms입니다.
-
#parallel_scan(cursor_count, options = {}) ⇒ Array<Cursor>
collection 보기에서 병렬 스캔을 실행합니다.
-
#read_concern ⇒ 해시
이 컬렉션 인스턴스에 대한 유효 읽기 고려를 가져옵니다.
-
#read_preference ⇒ 해시
이 컬렉션 에 대한 유효 읽기 설정 (read preference) 을 가져옵니다.
-
#replace_one(필터하다, 교체, 옵션 = {}) ⇒ 결과
컬렉션의 단일 문서를 새 문서로 바꿉니다.
-
#search_indexes(options = {}) ⇒ SearchIndex::View
이 컬렉션 에 대한 모든 검색 인덱스 보기를 가져옵니다.
-
#server_selector ⇒ Mongo::ServerSelector
이 컬렉션 에 대한 서버 선택기를 가져옵니다.
-
#system_collection? ⇒ 부울
비공개
컬렉션이 시스템 컬렉션인지 여부입니다.
-
#timeout_ms ⇒ Integer | nil
비공개
이 데이터베이스 또는 해당 클라이언트 에 대한 작업 시간 초과입니다.
-
#update_many(filter, update, options = {}) ⇒ Result
컬렉션 의 문서를 업데이트합니다.
-
#update_one(filter, update, options = {}) ⇒ Result
컬렉션 에서 단일 문서 를 업데이트합니다.
-
#watch(pipeline = [], options = {}) ⇒ ChangeStream
사용자가 특정 컬렉션 의 모든 변경사항에 대해 알림 보내도록 요청 수 있습니다.
-
#with(new_options) ⇒ Mongo::Collection
새 컬렉션 인스턴스 입니다.
-
#write_concern ⇒ Mongo::WriteConcern
이 컬렉션에 대한 유효 쓰기 고려를 가져옵니다.
-
#write_concern_with_session(세션) ⇒ Mongo::WriteConcern
비공개
지정된 세션에서 이 컬렉션 에 대한 작업에 사용할 쓰기 고려 (write concern) 고려를 가져옵니다.
헬퍼에 포함된 메서드
QueryableEncryption에 포함된 메서드
#maybe_create_qe_collections, #maybe_drop_emm_collections
Retryable에 포함된 메서드
#read_Worker, #select_server, #with_overload_retry, #write_Worker
생성자 세부 정보
#initialize(데이터베이스, name, options = {}) ⇒ Collection
새 컬렉션 을 인스턴스화합니다.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 163줄 def 초기화(database, 이름, = {}) 올리다 오류::InvalidCollectionName.신규 하지 않는 한 이름 만약 [:write] && [:write_concern] && [:write] != [:write_concern] 올리다 ArgumentError, ":write 및 :write_concern이 모두 지정된 경우, 둘 다 동일해야 합니다: #{.검사}" end @database = database @name = 이름.to_s.동결 @options = .dup @timeout_ms = .삭제(:timeout_ms) # WriteConcern 객체 지원 # if @options[:write_concern].is_a?(WriteConcern::Base) # # 인스턴스 를 캐시하여 불필요하게 재구성하지 않도록 합니다. # @write_concern = @options[:write_concern] # @options[:write_concern] = @write_concern.options # end @options.동결 end |
인스턴스 속성 세부 정보
#database ⇒ Mongo::Database (읽기 전용)
컬렉션 이 있는 데이터베이스 를 반환합니다.
44 45 46 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 44줄 def database @database end |
#이름 ⇒ string (읽기 전용)
컬렉션 의 이름을 반환합니다.
47 48 49 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 47줄 def 이름 @name end |
#options ⇒ 해시 (읽기 전용)
반환값 컬렉션 옵션.
50 51 52 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 50줄 def @options end |
인스턴스 메서드 세부 정보
#==(기타) ⇒ true | false
컬렉션 이 다른 객체 와 같은지 확인합니다. 이름과 데이터베이스 가 동일한지 확인합니다.
89 90 91 92 93 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 89줄 def ==(기타) 반환 거짓 하지 않는 한 기타.is_a?(컬렉션) 이름 == 기타.이름 && database == 기타.database && == 기타. end |
#aggregate(파이프라인, options = {}) ⇒ View::Aggregation
컬렉션 에 대해 집계 을 수행합니다.
567 568 569 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 567줄 def 집계(파이프라인, = {}) 보기.신규(self, {}, ).집계(파이프라인, ) end |
#bulk_write(요청, 옵션 = {}) ⇒ BulkWrite::Result
일괄 쓰기 (write) 작업을 배치 실행합니다.
939 940 941 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 939줄 def bulk_write(요청, = {}) 대량 쓰기.신규(self, 요청, ).실행 end |
#고정? ⇒ true | false
컬렉션 제한이 있나요?
317 318 319 320 321 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 317줄 def 고정? database.list_collections(필터: { 이름: 이름 }) .first &.dig('options', CCAPED) || 거짓 end |
#count(필터하다 = nil, options = {}) ⇒ 정수
대신 #count_documents 또는 expected_document_count를 사용하세요. 그러나 #count_documents로 전환할 때는 다음 연산자를 대체해야 합니다.
* $where should be replaced with $expr
* $near should be replaced with $geoWithin with $center
* $nearSphere should be replaced with $geoWithin with $centerSphere컬렉션 에서 일치하는 문서의 예상 수를 가져옵니다.
681 682 683 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 681줄 def 카운트(필터 = nil, = {}) 보기.신규(self, 필터 || {}, ).카운트() end |
#count_documents(필터하다 = {}, options = {}) ⇒ 정수
쿼리 와 일치하는 문서 수를 가져옵니다. 더 이상 사용되지 않는 #count 메서드와 달리 이 메서드는 추정치가 아닌 필터하다 와 일치하는 정확한 문서 수(또는 필터하다 가 제공되지 않은 경우 컬렉션 의 정확한 문서 수)를 반환합니다.
컬렉션 메타데이터 를 사용하여 컬렉션 내 문서 수의 추정치를 조회 하려면 #estimated_document_count 를 사용합니다.
715 716 717 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 715줄 def count_documents(필터 = {}, = {}) 보기.신규(self, 필터, ).count_documents() end |
#create(opts = {}) ⇒ 결과
데이터베이스 에 컬렉션 을 강제로 생성합니다.
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 378줄 def create(opts = {}) # 생성 명령에 읽기 옵션을 전달하면 명령이 중단됩니다. # 읽기 옵션을 필터링합니다. 세션도 다음과 같이 제외됩니다. # with_session 호출에 사용되며 다음의 일부가 되어서는 안 됩니다. 작업 #. 작업에 전달되면 실패 BSON # 직렬화. # TODO는 다음과 같은 경우 읽기 옵션 목록을 클래스 수준 상수에 넣습니다. # 전체 설정하다 가 무엇인지 알아냅니다. = 해시[self..merge(opts).거부 do |키, _value| %w[읽기 read_preference read_concern Session].포함?(키.to_s) end] # Ruby 옵션을 서버 스타일로 변환. CREATE_COLLECTION_OPTIONS.각 do |Ruby_key, server_key| [server_key] = .삭제(Ruby_key) 만약 .키?(Ruby_key) end 작업 = { 생성: 이름 }.merge() 작업.삭제(:write) 작업.삭제(:write_concern) 고객.send(:with_session, opts) do |Session| write_concern = 만약 opts[:write_concern] writeConcern.get(opts[:write_concern]) other self.write_concern end 컨텍스트 = 작업::Context.신규( 클라이언트: 고객, 세션: Session ) 작업 = 작업::만들기.신규( 선택기: 작업, db_name: database.이름, write_concern: write_concern, 세션: Session, # 이는 컬렉션 옵션이며 데이터 정렬은 # create 메서드에 전달된 옵션에서 가져옵니다. 데이터 정렬: [:collation] || ['데이터 정렬'], validator: [:validator] ) 트레이서.trace_operation(작업, 컨텍스트, op_name: ' createCollection ') do may_create_qe_collections(opts[:encrypted_fields], 고객, Session) do |encryption_fields| 작업.encryption_fields = encryption_fields 작업.실행( Next_primary(nil, Session), 컨텍스트: 컨텍스트 ) end end end end |
#delete_many(filter = nil, options = {}) ⇒ Result
컬렉션 에서 문서를 제거합니다.
991 992 993 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 991줄 def delete_many(필터 = nil, = {}) 찾기(필터, ).delete_many() end |
#delete_one(필터하다 = nil, options = {}) ⇒ 결과
컬렉션 에서 문서 를 제거합니다.
965 966 967 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 965줄 def delete_one(필터 = nil, = {}) 찾기(필터, ).delete_one() end |
#distinct(field_name, 필터하다 = nil, options = {}) ⇒ Array<Object>
특정 필드 에 대한 고유 값 목록을 가져옵니다.
767 768 769 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 767줄 def 별개(field_name, 필터 = nil, = {}) 보기.신규(self, 필터 || {}, ).별개(field_name, ) end |
#drop(opts = {}) ⇒ 결과
컬렉션 존재하지 않는 경우 반환되는 오류가 표시되지 않습니다.
컬렉션 을 삭제합니다. 컬렉션 과 관련된 모든 인덱스 및 연결된 Queryable Encryption 컬렉션도 삭제합니다.
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 451줄 def 제거(opts = {}) 고객.with_session(opts) do |Session| 컨텍스트 = 작업::Context.신규( 클라이언트: 고객, 세션: Session, operation_timeout: operation_timeout(opts) ) temp_write_concern = write_concern write_concern = 만약 opts[:write_concern] writeConcern.get(opts[:write_concern]) other temp_write_concern end 작업 = 작업::drop.신규({ 선택기: { drop: 이름 }, db_name: database.이름, write_concern: write_concern, 세션: Session, }) 트레이서.trace_operation(작업, 컨텍스트, op_name: 'dropCollection ') do may_drop_emm_collections(opts[:encrypted_fields], 고객, Session) do do_drop(작업, Session, 컨텍스트) end end end end |
#추정 _문서_카운트 (옵션 = {}) ⇒ 정수
컬렉션 메타데이터 를 사용하여 컬렉션 내 문서 수의 추정치를 가져옵니다.
컬렉션에 있는 정확한 문서 수를 검색하거나 필터와 일치하는 문서 수를 계산하려면 #count_documents를 사용합니다.
740 741 742 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 740줄 def 예상_문서_수( = {}) 보기.신규(self, {}, ).예상_문서_수() end |
#find(필터하다 = nil, options = {}) ⇒ CollectionView
컬렉션에서 문서를 찾습니다.
531 532 533 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 531줄 def 찾기(필터 = nil, = {}) 보기.신규(self, 필터 || {}, ) end |
#find_one_and_delete(필터하다, options = {}) ⇒ BSON::Document?
findAndModify를 통해 데이터베이스에서 단일 문서를 찾아 삭제하고 원본 문서를 반환합니다.
1164 1165 1166 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1164줄 def find_one_and_delete(필터, = {}) 찾기(필터, ).find_one_and_delete() end |
#find_one_and_replace(필터하다, 교체 , 옵션 = {}) ⇒ BSON::Document
단일 문서 를 찾아 대체하고, 달리 지정되지 않는 한 원본 문서를 반환합니다.
1250 1251 1252 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1250줄 def find_one_and_replace(필터, 교체, = {}) 찾기(필터, ).find_one_and_update(교체, ) end |
#find_one_and_update(filter, update, options = {}) ⇒ BSON::Document
findAndModify를 통해 단일 문서 를 찾아 업데이트하고, 달리 지정되지 않는 한 원본 문서를 반환합니다.
1208 1209 1210 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1208줄 def find_one_and_update(필터, update, = {}) 찾기(필터, ).find_one_and_update(update, ) end |
#indexes(options = {}) ⇒ Index::View
이 컬렉션 의 모든 인덱스 보기를 가져옵니다. 반복 가능하거나 더 많은 연산을 가질 수 있습니다.
784 785 786 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 784줄 def 인덱스( = {}) Index::보기.신규(self, ) end |
#insert_many(documents, options = {}) ⇒ Result
제공된 문서를 컬렉션에 삽입합니다.
907 908 909 910 911 912 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 907줄 def insert_many(문서, = {}) 쿼리 캐시.clear_namespace(namespace) 삽입 = 문서.map { |doc| { insert_one: doc } } bulk_write(삽입, ) end |
#insert_one(문서, opts = {}) ⇒ Result
컬렉션에 단일 문서를 삽입합니다.
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 845줄 def insert_one(문서, opts = {}) 쿼리 캐시.clear_namespace(namespace) 고객.with_session(opts) do |Session| write_concern = 만약 opts[:write_concern] writeConcern.get(opts[:write_concern]) other write_concern_with_session(Session) end 올리다 ArgumentError, ' 삽입할 문서는 nil일 수 없습니다. ' 만약 문서.nil? 컨텍스트 = 작업::Context.신규( 클라이언트: 고객, 세션: Session, operation_timeout: operation_timeout(opts) ) 작업 = 작업::Insert.신규( 문서: [ 문서 ], db_name: database.이름, coll_name: 이름, write_concern: write_concern, bypass_document_validation: !!opts[:bypass_document_validation], 옵션: opts, id_generator: 고객.[:id_generator], 세션: Session, comment: opts[:comment] ) 트레이서.trace_operation(작업, 컨텍스트) do write_with_retry(write_concern, 컨텍스트: 컨텍스트) do |연결, txn_num, 컨텍스트| 작업.txn_num = txn_num 작업.execution_with_connection(연결, 컨텍스트: 컨텍스트) end end end end |
#검사 ⇒ string
컬렉션 에 대한 예쁜 인쇄된 string 검사를 가져옵니다.
818 819 820 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 818줄 def 검사 "#<Mongo::Collection:0x#{object_id} 네임스페이스=#{네임스페이스}>" end |
#네임스페이스 ⇒ string
컬렉션 의 정규화된 네임스페이스 를 가져옵니다.
1262 1263 1264 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1262줄 def namespace "#{데이터베이스.name}.#{name}" end |
#operation_timeouts(opts = {}) ⇒ 해시
이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.
작업 수준에서 설정하다 timeout_ms 값(있는 경우) 및/또는 컬렉션/ 데이터베이스/ 클라이언트 수준(있는 경우)에 설정하다 timeout_ms를 반환합니다.
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1287줄 def operation_timeout(opts = {}) # TODO: 두 개의 타임아웃이 별도로 필요한지 다시 평가해야 합니다. {}.탭 do |결과| 만약 opts[:timeout_ms].nil? 결과[:inherited_timeout_ms] = timeout_ms other 결과[:operation_timeout_ms] = opts.삭제(:timeout_ms) end end end |
#parallel_scan(cursor_count, options = {}) ⇒ Array<Cursor>
collection 보기에서 병렬 스캔을 실행합니다.
동시에 반복할 수 있는 최대 cursor_count개의 커서 목록을 반환합니다. 스캔 중에 컬렉션 수정되지 않는 한 각 문서 커서의 결과 세트 중 하나에 한 번씩 나타납니다.
1022 1023 1024 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1022줄 def parallel_scan(cursor_count, = {}) 찾기({}, ).parallel_scan(cursor_count, ) end |
#read_concern ⇒ 해시
이 컬렉션 인스턴스에 대한 유효 읽기 고려를 가져옵니다.
컬렉션 옵션에 읽기 고려 (read concern) 제공된 경우 해당 읽기 고려 (read concern) 반환되고, 그렇지 않으면 데이터베이스의 유효 읽기 고려 (read concern) 반환됩니다.
194 195 196 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 194줄 def read_concern [:read_concern] || database.read_concern end |
#read_preference ⇒ 해시
이 컬렉션 에 대한 유효 읽기 설정 (read preference) 을 가져옵니다.
컬렉션 옵션에 읽기 설정 (read preference) 제공된 경우 해당 읽기 설정 (read preference) 반환되고, 그렇지 않으면 데이터베이스의 유효 읽기 설정 (read preference) 반환됩니다.
222 223 224 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 222줄 def read_preference @read_preference ||= [:read] || database.read_preference end |
#replace_one(필터하다, 교체, 옵션 = {}) ⇒ 결과
컬렉션의 단일 문서를 새 문서로 바꿉니다.
1058 1059 1060 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1058줄 def replace_one(필터, 교체, = {}) 찾기(필터, ).replace_one(교체, ) end |
#search_indexes(options = {}) ⇒ SearchIndex::View
ID 또는 이름 중 하나만 제공할 수 있습니다. 둘 다 지정하면 오류가 발생하지만, 둘 다 안전하게 생략할 수 있습니다.
이 컬렉션 에 대한 모든 검색 인덱스 보기를 가져옵니다. 반복하거나 직접 작업할 수 있습니다. ID 또는 이름이 제공되면 반복기는 표시된 인덱스 만 반환합니다. 다른 모든 작업의 경우 ID 와 이름은 무시됩니다.
806 807 808 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 806줄 def search_indexes( = {}) SearchIndex::보기.신규(self, ) end |
#server_selector ⇒ Mongo::ServerSelector
이 컬렉션 에 대한 서버 선택기를 가져옵니다.
206 207 208 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 206줄 def server_selector @server_selector ||= ServerSelector.get(read_preference || database.server_selector) end |
#system_collection? ⇒ 부울
이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.
컬렉션이 시스템 컬렉션인지 여부입니다.
1271 1272 1273 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1271줄 def system_collection? 이름.start_with?('시스템.') end |
#timeout_ms ⇒ Integer | nil
이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.
이 데이터베이스 또는 해당 클라이언트 에 대한 작업 시간 초과를 반환합니다.
1279 1280 1281 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1279줄 def timeout_ms @timeout_ms || database.timeout_ms end |
#update_many(filter, update, options = {}) ⇒ Result
컬렉션 의 문서를 업데이트합니다.
1091 1092 1093 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1091줄 def update_many(필터, update, = {}) 찾기(필터, ).update_many(update, ) end |
#update_one(filter, update, options = {}) ⇒ Result
컬렉션 에서 단일 문서 를 업데이트합니다.
1129 1130 1131 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 1129줄 def update_one(필터, update, = {}) 찾기(필터, ).update_one(update, ) end |
#watch(파이프라인 = [], options = {}) ⇒ ChangeStream
변경 스트림 '대다수' 읽기 고려 (read concern) 만 허용합니다.
재개 가능성을 지원할 목적으로 $changeStream 단계로 원시 애그리게이션을 실행하는 것보다 이 헬퍼 메서드를 사용하는 것이 좋습니다.
사용자가 특정 컬렉션 의 모든 변경사항에 대해 알림 보내도록 요청 수 있습니다.
642 643 644 645 646 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 642줄 def 시계(파이프라인 = [], = {}) = .dup [:cursor_type] = :tailable_await 만약 [:max_await_time_ms] 보기::Change Stream.신규(보기.신규(self, {}, ), 파이프라인, nil, ) end |
#with(new_options) ⇒ Mongo::Collection
반환값 새 컬렉션 인스턴스 반환합니다.
299 300 301 302 303 304 305 306 307 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 299줄 def 와() .키.각 do |k| 올리다 오류::UnchangeableCollectionOption.신규(k) 하지 않는 한 CHANGEABLE_OPTIONS.포함?(k) end = @options.dup .삭제(:write) 만약 [:write] && [:write_concern] .삭제(:write_concern) 만약 [:write_concern] && [:write] 컬렉션.신규(database, 이름, .update()) end |
#write_concern ⇒ Mongo::WriteConcern
이 컬렉션에 대한 유효 쓰기 고려를 가져옵니다.
컬렉션 옵션에 쓰기 고려 (write concern) 제공된 경우 해당 쓰기 고려 (write concern) 반환되고, 그렇지 않으면 데이터베이스의 유효 쓰기 고려 (write concern) 반환됩니다.
238 239 240 241 242 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 238줄 def write_concern @write_concern ||= writeConcern.get( [:write_concern] || [:write] || database.write_concern ) end |
#write_concern_with_session(세션) ⇒ Mongo::WriteConcern
이 메서드는 비공개 API의 일부입니다. 이 방법은 향후 제거되거나 변경될 수 있으므로 가능하면 사용하지 않는 것이 좋습니다.
지정된 세션에서 이 컬렉션 에 대한 작업에 사용할 쓰기 고려 (write concern) 고려를 가져옵니다.
세션이 트랜잭션 중이고 컬렉션 승인되지 않은 쓰기 고려 (write concern) 있는 경우 쓰기 (write) 고려의 :w 옵션을 제거 . 그렇지 않으면 수정되지 않은 쓰기 고려 (write concern) 반환합니다.
255 256 257 258 259 260 261 262 263 |
# 파일 'lib/ Mongo/ 컬렉션.rb', 255줄 def write_concern_with_session(Session) wc = write_concern 만약 Session && Session.in_transaction? && wc && !wc.인정? opts = wc..dup opts.삭제(:w) 반환 writeConcern.get(opts) end wc end |