Last active
December 18, 2015 07:19
-
-
Save jcblw/5745798 to your computer and use it in GitHub Desktop.
New methods for Mangos
This file contains 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
// 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