Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var express = require('express');
var User = require('../model/user');
var mongoose = require('mongoose');
var router = express.Router();
router.post('/insertUser', function(req, res, next) {
var newUser = new User(req.body);
newUser._id = mongoose.Types.ObjectId();
newUser.save(function(err) {
if (err) {
console.log("not saved!");
res.status(400);
res.send();
}
console.log("saved!");
res.send({ id : newUser._id });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment