Need a little more information than that.
I've attached the MXUnit tests for this if that helps
On 15/10/2012 07:31, jojoe wrote:
I have problem to use gridfs. Can you help me. -
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en
// ---------------------------------------------------------------------------------
function testAddRemoveFindOne(){
MongoRegister( name="mongo", server="127.0.0.1", db="openbd" );
var id = MongoGridfsSave( "mongo", "filebucket", ExpandPath("MongoDatabase.cfc"), "mongodatabase.cfc", "text/plain", "4f6e7d23c243305d41cd748c", {custom1:1, custom2:"age"} );
var f = MongoGridfsFindOne(datasource="mongo", bucket="filebucket", _id=id);
assertEquals( f._id, "4f6e7d23c243305d41cd748c" );
assertEquals( f.filename, "mongodatabase.cfc" );
assertEquals( f.contentType, "text/plain" );
assertTrue( f.length > 0 );
assertEquals( f.metadata.custom1, 1 );
assertEquals( f.metadata.custom2, "age" );
// Delete it from the database
MongoGridfsRemove( datasource="mongo", bucket="filebucket", _id=id );
f = MongoGridfsFindOne(datasource="mongo", bucket="filebucket", _id=id);
assertTrue( StructCount(f) == 0 );
}
// ---------------------------------------------------------------------------------
function testAddFindRemove(){
MongoRegister( name="mongo", server="127.0.0.1", db="openbd" );
var id = MongoGridfsSave( "mongo", "filebucket", ExpandPath("MongoDatabase.cfc"), "mongodatabase.cfc", "text/plain", "4f6e7d23c243305d41cd748c", {custom1:1, custom2:"age"} );
var arry = MongoGridfsFind(datasource="mongo", bucket="filebucket", query={filename:"mongodatabase.cfc"} );
assertTrue( ArrayLen(arry) == 1 );
// Delete it from the database
MongoGridfsRemove( datasource="mongo", bucket="filebucket", _id=id );
f = MongoGridfsFindOne(datasource="mongo", bucket="filebucket", _id=id);
assertTrue( StructCount(f) == 0 );
}
// ---------------------------------------------------------------------------------
function testAddGetRemove(){
MongoRegister( name="mongo", server="127.0.0.1", db="openbd" );
var id = MongoGridfsSave( "mongo", "filebucket", ExpandPath("MongoDatabase.cfc"), "mongodatabase.cfc", "text/plain", "4f6e7d23c243305d41cd748c", {custom1:1, custom2:"age"} );
var res = MongoGridfsGet(datasource="mongo", bucket="filebucket", filepath=ExpandPath('deleteme.cfc'), _id=id );
assertTrue( res );
FileDelete( ExpandPath('deleteme.cfc') );
// Delete it from the database
MongoGridfsRemove( datasource="mongo", bucket="filebucket", _id=id );
f = MongoGridfsFindOne(datasource="mongo", bucket="filebucket", _id=id);
assertTrue( StructCount(f) == 0 );
}