GridStore#mv
This commit is contained in:
parent
8a8d6716b3
commit
3b30cde0fb
|
@ -118,7 +118,7 @@ module GridFS
|
||||||
gs.readlines(separator)
|
gs.readlines(separator)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink(db, *names)
|
def unlink(db, *names)
|
||||||
names.each { |name|
|
names.each { |name|
|
||||||
gs = GridStore.new(db, name)
|
gs = GridStore.new(db, name)
|
||||||
|
@ -128,6 +128,10 @@ module GridFS
|
||||||
end
|
end
|
||||||
alias_method :delete, :unlink
|
alias_method :delete, :unlink
|
||||||
|
|
||||||
|
def mv(db, src, dest, root_collection=DEFAULT_ROOT_COLLECTION)
|
||||||
|
db.collection("#{root_collection}.files").update({ :filename => src }, { '$set' => { :filename => dest } })
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#---
|
#---
|
||||||
|
|
|
@ -151,6 +151,16 @@ class GridStoreTest < Test::Unit::TestCase
|
||||||
assert_equal 0, @@files.count
|
assert_equal 0, @@files.count
|
||||||
assert_equal 0, @@chunks.count
|
assert_equal 0, @@chunks.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_mv
|
||||||
|
assert_equal 1, @@files.count
|
||||||
|
assert_equal 1, @@chunks.count
|
||||||
|
GridStore.mv(@@db, 'foobar', 'bazqux')
|
||||||
|
assert_equal 1, @@files.count
|
||||||
|
assert_equal 1, @@chunks.count
|
||||||
|
assert !GridStore.exist?(@@db, 'foobar')
|
||||||
|
assert GridStore.exist?(@@db, 'bazqux')
|
||||||
|
end
|
||||||
|
|
||||||
def test_append
|
def test_append
|
||||||
GridStore.open(@@db, 'foobar', 'w+') { |f| f.write(" how are you?") }
|
GridStore.open(@@db, 'foobar', 'w+') { |f| f.write(" how are you?") }
|
||||||
|
|
Loading…
Reference in New Issue