本文整理汇总了C++中GridFS::list方法的典型用法代码示例。如果您正苦于以下问题:C++ GridFS::list方法的具体用法?C++ GridFS::list怎么用?C++ GridFS::list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridFS
的用法示例。
在下文中一共展示了GridFS::list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gridfs_list
/*
* cursor,err = gridfs:list([lua_table or json_str])
*/
static int gridfs_list(lua_State *L) {
GridFS *gridfs = userdata_to_gridfs(L, 1);
BSONObj query;
int type = lua_type(L, 2);
if (type == LUA_TSTRING) {
const char *jsonstr = luaL_checkstring(L, 2);
query = fromjson(jsonstr);
} else if (type == LUA_TTABLE) {
lua_to_bson(L, 2, query);
}
std::auto_ptr<DBClientCursor> autocursor = gridfs->list(query);
if (!autocursor.get()){
lua_pushnil(L);
lua_pushstring(L, LUAMONGO_ERR_CONNECTION_LOST);
return 2;
}
DBClientCursor **cursor = (DBClientCursor **)lua_newuserdata(L, sizeof(DBClientCursor *));
*cursor = autocursor.get();
autocursor.release();
luaL_getmetatable(L, LUAMONGO_CURSOR);
lua_setmetatable(L, -2);
return 1;
}
示例2: gridfs_list
/*
* cursor,err = gridfs:list()
*/
static int gridfs_list(lua_State *L) {
GridFS *gridfs = userdata_to_gridfs(L, 1);
std::auto_ptr<DBClientCursor> autocursor = gridfs->list();
if (!autocursor.get()) {
lua_pushnil(L);
lua_pushstring(L, LUAMONGO_ERR_CONNECTION_LOST);
return 2;
}
DBClientCursor **cursor = (DBClientCursor **)lua_newuserdata(L, sizeof(DBClientCursor *));
*cursor = autocursor.get();
autocursor.release();
luaL_getmetatable(L, LUAMONGO_CURSOR);
lua_setmetatable(L, -2);
return 1;
}