Answer the question
In order to leave comments, you need to log in
How to enable mongoose-auto-increment?
Is:
app.js
...
mongoose = require('mongoose');
mongoose.connect(config.url);
...
module.exports = {
'secret': 'ilovescotchyscotch',
'url': 'mongodb://localhost/bd'
};
var mongoose = require('mongoose');
module.exports = mongoose.model('Admin',{
username: String,
password: String,
email: String,
role: { type: String, default: "user" },
soft_token: { type: String, default: 0 }
});
var User = require('../models/user');
router.get('/test', function (req, res, next) {
new User({
//..//..//
});
});
Answer the question
In order to leave comments, you need to log in
do not export the Admin model immediately, but save it to a variable, for example, AdminSchema:
let AdminSchema = new mongoose.Schema({
username…
…..
});
let Admin = mongoose.model('Admin', accountSchema);
modules.exports = Admin;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question