mirror of
https://github.com/Febbweiss/CloudBudget.git
synced 2026-03-05 06:45:39 +00:00
Feature: returns a list of entries when creating, editing or deleting an entry
This commit is contained in:
@@ -143,8 +143,19 @@ module.exports = {
|
||||
return Handler.errorHandler(errors, 400, response);
|
||||
}
|
||||
|
||||
response.status(201).json(entry);
|
||||
})
|
||||
Entry
|
||||
.find({account_id: account.id})
|
||||
.sort({date: -1})
|
||||
.exec(function(errors, entries) {
|
||||
if( errors ) {
|
||||
return Handler.errorHandler(errors, 500, response);
|
||||
}
|
||||
response.status(201).json({
|
||||
entry: entry,
|
||||
entries: entries
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -177,7 +188,18 @@ module.exports = {
|
||||
return Handler.errorHandler(errors, 400, response );
|
||||
}
|
||||
|
||||
return response.json(entry);
|
||||
Entry
|
||||
.find({account_id: account.id})
|
||||
.sort({date: -1})
|
||||
.exec(function(errors, entries) {
|
||||
if( errors ) {
|
||||
return Handler.errorHandler(errors, 500, response);
|
||||
}
|
||||
response.status(200).json({
|
||||
entry: entry,
|
||||
entries: entries
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -203,7 +225,18 @@ module.exports = {
|
||||
return Handler.errorHandler(errors, 500, response);
|
||||
}
|
||||
|
||||
return response.status(204).end();
|
||||
Entry
|
||||
.find({account_id: account.id})
|
||||
.sort({date: -1})
|
||||
.exec(function(errors, entries) {
|
||||
if( errors ) {
|
||||
return Handler.errorHandler(errors, 500, response);
|
||||
}
|
||||
response.status(204).json({
|
||||
entry: entry,
|
||||
entries: entries
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,5 +16,8 @@ var EntrySchema = new Schema({
|
||||
created_at: {type: Date, default: Date.now}
|
||||
});
|
||||
|
||||
EntrySchema.index({account_id: 1, date: -1, type: 1});
|
||||
EntrySchema.index({account_id: 1, date: -1, category: 1, sub_category: 1});
|
||||
|
||||
var Entry = mongoose.model('Entry', EntrySchema);
|
||||
module.exports = Entry;
|
||||
Reference in New Issue
Block a user