Skip to content

Instantly share code, notes, and snippets.

@jcblw
Last active December 18, 2015 07:19
Show Gist options
  • Save jcblw/5745798 to your computer and use it in GitHub Desktop.
Save jcblw/5745798 to your computer and use it in GitHub Desktop.
New methods for Mangos
// eg.
var
Mangos = require("mangos"),
connection = new Mangos("supercooldb", "127.0.0.1", 27101),
model = {
//when adding or updating or returning
defaults : { // default values for model
first_name : "Bob",
last_name : "Hope",
notifications : true
},
//when adding or updating
allowOnly : [ // limit what keys can be saved _id will always be allowed
"first_name",
"last_name",
"password",
"notifications",
"username",
"token",
"salt"
],
//when adding or updating
autoUpdate : true, // updates keys in db if out of sync with model
//when returning
privateKeys : [ // keys that will never be returned
"password",
"salt"
]
},
users = connection.Collection( "users" , model )
users.read( ... )
users.create( ... )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment