DF and Mongodb agregation $sum , $inc

Hi dear Dreamfactory users and dev’s

i’ve implemented Mongodb for a part of my project (quote and invoice part) because of the nosql flexibility.
(after trying Couchdb…)

i can make CreateRecord, GetRecord etc… without any problem
IN API DOC for example
i can also make get Record with filter
{“numerodevis”:{"$gt":20}} for filtering quote (devis) greater than 20
and
{“numerodevis”:{"$in":[2,7]}} : for filtering quotenumber 2 and 7

now i’m looking on how implementing 2 thing

1/ Implementing $sum in filter
a GetRecord with $sum in filter
so i try
{“idSalesCount” : { “$sum” : “$total” }}
who return : invalid operator: $sum",

2/ implementing Mongodb incrementation $inc
i’ve try several time thought updateRecords, UpdateRecordsbyfilter etc…
i now thanks to this post
https://blog.dreamfactory.com/blog/bid/339945/NoSQL-No-Problem-MongoDB-Specifics
that i need to use a PATCH
but when i try DSP create en entry
“$inc”: {
“devis”: NumberLong(1)
},
instead of updating…

****UPDATED N°2 Solved by myself ****
you should do a PUT/ReplaceRecords and not patch/something



So, as $inc and $set are fine
Does anyone have an idea on how doing a $sum ?.

thanks

$sum appears to require aggregation first. (Mongo Docs)
Are you performing the aggregation in this call?

Hi Drew
that’s the point i’m looking on how performing aggregation with $sum with DSP
thanks for your help

is there any answer for SUM() ?

It’s not in the current release, but there are plans to add aggregate functions to NoSQL, similar to how it was done for SQL. Don’t have an ETA, but it’s on the horizon.

Thanks Drew definitely looking forward to it! May I suggest if custom script can use actual mongodb direct command or mongo script call it would be super awesome! I may not speak for everyone, but some of us would like higher flexibility on mongodb custom script =)

1 Like

hi,

Are te aggregate functions in? Thanks

this could be awesome, if we can aggregate filters to the aggregate pipeline in the custom script window, and use all the current functionality in mongodb

1 Like