Created
October 16, 2014 09:27
-
-
Save henryoswald/aca1545987f2360c4bd4 to your computer and use it in GitHub Desktop.
gzip project data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var zlib = require('zlib'); | |
var ObjectId, UserGetter, db, mongojs; | |
mongojs = require("../../infrastructure/mongojs"); | |
console.log("hello") | |
db = mongojs.db; | |
ObjectId = mongojs.ObjectId; | |
gzipProject = function(query, callback) { | |
if (callback == null) { | |
callback = function(error, user) {}; | |
} | |
if (typeof query === "string") { | |
console.log("string") | |
query = { | |
_id: ObjectId(query) | |
}; | |
} else if (query instanceof ObjectId) { | |
query = { | |
_id: query | |
}; | |
} | |
console.log(query) | |
db.projects.findOne(query, function(err, project){ | |
console.log(project.rootFolder.buffer) | |
zlib.inflate(project.rootFolder, function (_, result) { // The callback will give you the | |
console.log(_, result); // result, so just send it. | |
var gzipedRootFoler = result; | |
var update = {$set: {rootFolder: gzipedRootFoler}} | |
//db.projects.update(query, update, callback) | |
}); | |
// console.log(project, callback) | |
}) | |
} | |
gzipProject("4eecaffcbffa66588e00000d", function(){ | |
console.log("done") | |
}) | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment