reformat with prettier,add react frontend submodule

This commit is contained in:
2018-06-03 12:47:23 +03:00
parent 38688491f9
commit bbee6b2b95
16 changed files with 255 additions and 58 deletions

View File

@@ -14,7 +14,7 @@ const TodoListSchema = Schema({
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
});
TodoListSchema.pre('save', async function () {
TodoListSchema.pre('save', async function() {
if (this.isNew) {
const user = await this.model('User').findById(this.user);
user.lists.push(this._id);
@@ -22,7 +22,7 @@ TodoListSchema.pre('save', async function () {
}
});
TodoListSchema.pre('remove', async function () {
TodoListSchema.pre('remove', async function() {
const user = await this.model('User').findById(this.user);
user.lists.splice(user.lists.indexOf(this._id), 1);
@@ -41,8 +41,10 @@ TodoListSchema.pre('remove', async function () {
.exec();
});
TodoListSchema.methods.toJson = function () {
const todos = this.populated('todos') ? this.todos.map(todo => todo.toJson()) : this.todos;
TodoListSchema.methods.toJson = function() {
const todos = this.populated('todos')
? this.todos.map(todo => todo.toJson())
: this.todos;
return {
id: this._id.toString(),
user: this.user.toString(),