You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
localmongo=require('mongo')
-- Create a connection objectlocaldb=assert(mongo.Connection.New())
-- connect to the server on localhostassert(db:connect('localhost'))
-- create a GridFileBuilder handlelocalgridfs=mongo.GridFS.New(db, 'test')
localbuilder=assert(mongo.GridFileBuilder.New(gridfs) )
-- example loop generating data on-the-flyfori=1,100doassert(builder:append(string.format("Line number %d\n", i)))
end-- set the name of the file and it will be visible in GridFSassert(builder:build('myfile.txt'))
-- create a GridFS handlelocalgridfs=assert(mongo.GridFS.New(db, 'test'))
localgridfile=assert(gridfs:find_file('myfile.txt'))
-- print file contentfori=1,gridfile:num_chunks() dolocalchunk=assert(gridfile:chunk(i-1))
io.write(chunk:data())
end