diff --git a/app/models/note.js b/app/models/note.js index e1be838..705ca20 100644 --- a/app/models/note.js +++ b/app/models/note.js @@ -9,6 +9,9 @@ const NoteSchema = new Schema({ text: { type: String, required: [true, "can't be blank"], }, + user: { + type: Schema.Types.ObjectId, ref: 'User', + }, }, { timestamps: true }); module.exports = NoteSchema; diff --git a/app/models/user.js b/app/models/user.js index 4f8b98b..f176304 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -9,8 +9,8 @@ const UserSchema = new Schema({ lastname: { type: String, required: [true, "can't be blank"], }, - username: { - type: String, lowercase: true, unique: true, required: [true, "can't be blank"], match: [/^[a-zA-Z0-9]+$/, 'is invalid'], index: true, + email: { + type: String, lowercase: true, unique: true, required: [true, "can't be blank"], index: true, }, password: { type: String, required: [true, "can't be blank"],