mongodb - What's the easiest way to store a large object in Meteor using GridFS? -


I'm trying to backup a lunar index to Mongo (daily), and because it's running around 13 MB I'm triggering MongoError: The document is bigger than the overlay size Errors I would like to use GridFS to solve the problem, but I have a glimpse of a time to click .

In simple words: Within the meteor, I want to save a 13 MB JSON object using the gridfaces, and then be able to retrieve it if necessary - only on the server.

I have gone through the file-archive and archivefox docs, and they are still very complex for what I am trying to accomplish, and processing only the contents of a variable (Or, more likely to be, they do, and I just do not remember it.)

This is what I want to do, in the phony code: / P>

  backup = new GridFSCollection ('backup'); Var backdata = (sorted search index data object); Backup.insert ({name: 'searchindex', data: backup data, date: new date). GetTime ()}); Recover Var = Backup. FindOn ({name: 'searchindex'});  

Any suggestions?

  var db = MongoInternals.defaultRemoteCollectionDriver () . Mongo.db; Var GridStore = MongoInternals.NpmModule.GridStore; Var largedata = new GridStore (db, 'name', 'w'); // largedata.open (function (error, gs) {if (error) returns; gs.write ('somebigdata', function (error, done) {if (error) return; largedata.close ();})} ); Var largedata = new gridstore (db, 'name', 'r'); // data largedata.open to read (function (error, gs) returns {if (error); gs.read (function (error, result) {if (error) return; // Then results with largedata.close Do ();})}); 

Explanation

First you need a DB object, which can be exposed through Mongo International

Then you can write one or read the object and follow the API

Mongolia used by the meteor is 1.3.x while the latest node mongodb native driver is 2.xx

then AP E may change in the future. Currently, you need to open and close and callbacks are all ASCIN, you want to wrap them with Meteor.wrapAsync (can not work on largedata.open), future or fiber


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -