new Collection#options method
This commit is contained in:
parent
459381b9e4
commit
8aed3abda6
|
@ -66,8 +66,6 @@ type
|
|||
|
||||
* Capped collection support.
|
||||
|
||||
* More code comments. More text in this file.
|
||||
|
||||
* Support more types: REF, SYMBOL, CODE_W_SCOPE, etc.
|
||||
|
||||
* Introduce optional per-database and per-collection PKInjector.
|
||||
|
|
|
@ -112,6 +112,13 @@ module XGen
|
|||
@db.index_information(@name)
|
||||
end
|
||||
|
||||
# Return a hash containing options that apply to this collection.
|
||||
# 'create' will be the collection name. For the other possible keys
|
||||
# and values, see DB#create_collection.
|
||||
def options
|
||||
@db.collections_info(@name).next_object()['options']
|
||||
end
|
||||
|
||||
# Return the number of records that match +selector+. If +selector+ is
|
||||
# +nil+ or an empty hash, returns the count of all records.
|
||||
def count(selector={})
|
||||
|
|
|
@ -175,6 +175,22 @@ class DBAPITest < Test::Unit::TestCase
|
|||
assert_equal @coll.name, row['options']['create']
|
||||
end
|
||||
|
||||
def test_collection_options
|
||||
@db.drop_collection('foobar')
|
||||
@db.strict = true
|
||||
|
||||
begin
|
||||
coll = @db.create_collection('foobar', :capped => true, :size => 1024)
|
||||
options = coll.options()
|
||||
assert_equal 'foobar', options['create']
|
||||
assert_equal true, options['capped']
|
||||
assert_equal 1024, options['size']
|
||||
rescue => ex
|
||||
@db.drop_collection('foobar')
|
||||
fail "did not expect exception \"#{ex}\""
|
||||
end
|
||||
end
|
||||
|
||||
def test_full_coll_name
|
||||
assert_equal @coll_full_name, @db.full_coll_name(@coll.name)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue