Skip to content

Commit 5f6dd7e

Browse files
facttic/mv-issues#58 Add exec() and details
1 parent 3f73a9f commit 5f6dd7e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

deny_list/dao.js

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ DenyListSchema.statics.getByUserIdStrByManifestationId = async function getByUse
6565

6666
DenyListSchema.statics.removeById = async function removeById(_id, userId = null) {
6767
const { nModified } = await DenyListDAO.deleteById(_id, userId).exec();
68+
6869
// nModified will be 1 when _id exists
6970
if (nModified) {
7071
return _id;

manifestation/dao.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ ManifestationSchema.statics.createNew = async function createNew(manifestation)
1414

1515
// TODO: googlear y revisar como mergear las propiedades del objeto existente
1616
ManifestationSchema.statics.udpate = async function udpate(_id, manifestation) {
17-
return await ManifestationDAO.findByIdAndUpdate({ _id }, manifestation, {
17+
return await ManifestationDAO.findByIdAndUpdate(_id, manifestation, {
1818
new: true,
1919
runValidators: true,
2020
}).exec();
2121
};
2222

2323
ManifestationSchema.statics.getAll = async function getAll({ skip, limit, sort, query }) {
24-
const manifestationsTotal = await ManifestationDAO.countDocuments({ deleted: false });
24+
const manifestationsTotal = await ManifestationDAO.countDocuments({ deleted: false }).exec();
2525
const manifestations = await ManifestationDAO.find({ ...query })
2626
.skip(skip)
2727
.limit(limit)
28-
.sort(sort);
28+
.sort(sort)
29+
.exec();
30+
2931
return {
3032
count: manifestations.length,
3133
list: manifestations,
@@ -39,6 +41,7 @@ ManifestationSchema.statics.getById = async function getById(_id) {
3941

4042
ManifestationSchema.statics.removeById = async function removeById(_id, userId = null) {
4143
const { nModified } = await ManifestationDAO.deleteById(_id, userId).exec();
44+
4245
// nModified will be 1 when _id exists
4346
if (nModified) {
4447
return _id;

post/dao.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ PostSchema.statics.getById = async function getById(_id) {
5959
};
6060

6161
PostSchema.statics.removeByUserIdStr = async function removeByUserIdStr(userIdStr, userId = null) {
62-
const { nModified } = await PostDAO.delete({ "user.id_str": userIdStr }, userId);
62+
const { nModified } = await PostDAO.delete({ "user.id_str": userIdStr }, userId).exec();
6363

6464
if (nModified) {
6565
return userIdStr;
@@ -68,7 +68,7 @@ PostSchema.statics.removeByUserIdStr = async function removeByUserIdStr(userIdSt
6868
};
6969

7070
PostSchema.statics.removeById = async function removeById(_id, userId = null) {
71-
const { nModified } = await PostDAO.deleteById(_id, userId);
71+
const { nModified } = await PostDAO.deleteById(_id, userId).exec();
7272

7373
if (nModified) {
7474
return _id;
@@ -81,7 +81,10 @@ PostSchema.statics.removeByIdByManifestationId = async function removeByIdByMani
8181
_id,
8282
userId = null,
8383
) {
84-
const { nModified } = await PostDAO.delete({ _id, manifestation_id: manifestationId }, userId);
84+
const { nModified } = await PostDAO.delete(
85+
{ _id, manifestation_id: manifestationId },
86+
userId,
87+
).exec();
8588

8689
if (nModified) {
8790
return _id;

0 commit comments

Comments
 (0)