Skip to content

Instantly share code, notes, and snippets.

@diggzhang
Created December 25, 2015 07:14
Show Gist options
  • Save diggzhang/0ac81df0729a2109c2e2 to your computer and use it in GitHub Desktop.
Save diggzhang/0ac81df0729a2109c2e2 to your computer and use it in GitHub Desktop.
extend script of mongoshell
DBCollection.prototype.sample = function () {
return this.find();
}
DBCollection.prototype.onedoc = function (userId) {
return this.findOne({"_id": ObjectId(userId)});
}
DBCollection.prototype.pipeline = function (pipeline) {
return this.find(pipeline);
}
DBCollection.prototype.findId = function (userId, pipeline) {
return this.find({"_id": ObjectId(userId)}, pipeline);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment