File tree 3 files changed +13
-6
lines changed
3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ DenyListSchema.statics.getByUserIdStrByManifestationId = async function getByUse
65
65
66
66
DenyListSchema . statics . removeById = async function removeById ( _id , userId = null ) {
67
67
const { nModified } = await DenyListDAO . deleteById ( _id , userId ) . exec ( ) ;
68
+
68
69
// nModified will be 1 when _id exists
69
70
if ( nModified ) {
70
71
return _id ;
Original file line number Diff line number Diff line change @@ -14,18 +14,20 @@ ManifestationSchema.statics.createNew = async function createNew(manifestation)
14
14
15
15
// TODO: googlear y revisar como mergear las propiedades del objeto existente
16
16
ManifestationSchema . statics . udpate = async function udpate ( _id , manifestation ) {
17
- return await ManifestationDAO . findByIdAndUpdate ( { _id } , manifestation , {
17
+ return await ManifestationDAO . findByIdAndUpdate ( _id , manifestation , {
18
18
new : true ,
19
19
runValidators : true ,
20
20
} ) . exec ( ) ;
21
21
} ;
22
22
23
23
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 ( ) ;
25
25
const manifestations = await ManifestationDAO . find ( { ...query } )
26
26
. skip ( skip )
27
27
. limit ( limit )
28
- . sort ( sort ) ;
28
+ . sort ( sort )
29
+ . exec ( ) ;
30
+
29
31
return {
30
32
count : manifestations . length ,
31
33
list : manifestations ,
@@ -39,6 +41,7 @@ ManifestationSchema.statics.getById = async function getById(_id) {
39
41
40
42
ManifestationSchema . statics . removeById = async function removeById ( _id , userId = null ) {
41
43
const { nModified } = await ManifestationDAO . deleteById ( _id , userId ) . exec ( ) ;
44
+
42
45
// nModified will be 1 when _id exists
43
46
if ( nModified ) {
44
47
return _id ;
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ PostSchema.statics.getById = async function getById(_id) {
59
59
} ;
60
60
61
61
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 ( ) ;
63
63
64
64
if ( nModified ) {
65
65
return userIdStr ;
@@ -68,7 +68,7 @@ PostSchema.statics.removeByUserIdStr = async function removeByUserIdStr(userIdSt
68
68
} ;
69
69
70
70
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 ( ) ;
72
72
73
73
if ( nModified ) {
74
74
return _id ;
@@ -81,7 +81,10 @@ PostSchema.statics.removeByIdByManifestationId = async function removeByIdByMani
81
81
_id ,
82
82
userId = null ,
83
83
) {
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 ( ) ;
85
88
86
89
if ( nModified ) {
87
90
return _id ;
You can’t perform that action at this time.
0 commit comments