Model

suggest change

Define your model(s):

app/models/user.js (ES2015). This file needs "type": "module" or a .mjs extension. password here is only a field name. Store a hash before saving a real password.

import mongoose from 'mongoose';

const userSchema = new mongoose.Schema({
    name: String,
    password: String
});

const User = mongoose.model('User', userSchema);

export default User;

app/models/user.js (ES5)

var mongoose = require('mongoose');

var userSchema = new mongoose.Schema({
    name: String,
    password: String
});

var User = mongoose.model('User', userSchema);

module.exports = User

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents