pull/1/head
sundowndev 2018-11-13 18:46:44 +01:00
parent 78fd638195
commit 95c8a65bc2
2 changed files with 22 additions and 24 deletions

View File

@ -1,9 +1,14 @@
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
const mongoose = require('mongoose');
var NoteSchema = new Schema({
title: String,
text: String
});
const { Schema } = mongoose;
module.exports = mongoose.model('Note', NoteSchema);
const NoteSchema = new Schema({
title: {
type: String, required: [true, "can't be blank"],
},
text: {
type: String, required: [true, "can't be blank"],
},
}, { timestamps: true });
module.exports = NoteSchema;

View File

@ -1,25 +1,18 @@
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var bcrypt = require('bcrypt-nodejs');
const mongoose = require('mongoose');
var UserSchema = new Schema({
const { Schema } = mongoose;
const UserSchema = new Schema({
firstname: {
type: String,
required: true
type: String, required: [true, "can't be blank"],
},
lastname: {
type: String,
required: true
type: String, required: [true, "can't be blank"],
},
username: {
type: String,
unique: true,
required: true
type: String, lowercase: true, unique: true, required: [true, "can't be blank"], match: [/^[a-zA-Z0-9]+$/, 'is invalid'], index: true,
},
password: {
type: String,
required: true
}
});
password: String,
}, { timestamps: true });
module.exports = mongoose.model('User', UserSchema);
module.exports = UserSchema;