RUBY-304 add Collection#capped?
This commit is contained in:
parent
a323911507
commit
a9b975eaaa
|
@ -88,6 +88,16 @@ module Mongo
|
|||
@hint = nil
|
||||
end
|
||||
|
||||
# Indicate whether this is a capped collection.
|
||||
#
|
||||
# @raise [Mongo::OperationFailure]
|
||||
# if the collection doesn't exist.
|
||||
#
|
||||
# @return [Boolean]
|
||||
def capped?
|
||||
@db.command({:collstats => @name})['capped'] == 1
|
||||
end
|
||||
|
||||
# Return a sub-collection of this collection by name. If 'users' is a collection, then
|
||||
# 'users.comments' is a sub-collection of users.
|
||||
#
|
||||
|
|
|
@ -10,6 +10,16 @@ class TestCollection < Test::Unit::TestCase
|
|||
@@test.remove
|
||||
end
|
||||
|
||||
def test_capped_method
|
||||
@@db.create_collection('normal')
|
||||
assert !@@db['normal'].capped?
|
||||
@@db.drop_collection('normal')
|
||||
|
||||
@@db.create_collection('c', :capped => true)
|
||||
assert @@db['c'].capped?
|
||||
@@db.drop_collection('c')
|
||||
end
|
||||
|
||||
def test_optional_pk_factory
|
||||
@coll_default_pk = @@db.collection('stuff')
|
||||
assert_equal BSON::ObjectId, @coll_default_pk.pk_factory
|
||||
|
|
Loading…
Reference in New Issue