Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created May 14, 2015 05:52
Show Gist options
  • Save ajcrites/a04b5d7b637ea0639420 to your computer and use it in GitHub Desktop.
Save ajcrites/a04b5d7b637ea0639420 to your computer and use it in GitHub Desktop.
var mongoose = require("mongoose"),
db = mongoose.connect("mongodb://localhost"),
Schema = mongoose.Schema,
_ = require("lodash")
;
var UserSchema = new Schema({
provider: String,
name: String,
email: String,
hashedPassword: String,
salt: String,
drafts: ["Skim"],
starredSkims: ["Skim"],
skimsCreated: ["Skim"],
role: String,
});
mongoose.model("User", UserSchema);
var User = mongoose.model("User");
var SkimSchema = new Schema({
skim: String,
});
var user = new User({
provider: "local",
name: "Adam",
email: "[email protected]",
hashedPassword: "foo",
salt: "bar",
drafts: [],
starredSkims: [],
skimsCreated: [],
role: "user",
});
user.save(function (err, user) {
User.findById(user._id, function (err, user) {
var updated = _.extend(user, {});
updated.increment();
user.save(function (err) {
console.log(err);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment