userschema.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
UserSchema = new mongoose.Schema({
username: String,
phone: {
type: Number,
default: 9999999999
},
credits: {
type: Number,
default: 0
},
password: String
});
var User = module.exports = mongoose.model('User', UserSchema);
в вашем файле app.js или index.js:
var User=require('userschema.js');
app.post('/update/:id',function(req,res){
var username=req.body.username;
User.update({_id:req.params.id},{$set:{username:username}},function(err){
if(!err){return res.json({status:"success",message:"username updated"});}
});
});