classfantorepo302::MongoUtils
sys::Obj fantorepo302::MongoUtils
MongoUtils Addons and utility methods for dealing with mongo - stuff that FanLink doesn't do
- atomicInc
static Void atomicInc(DB db, Type mongoDocType, Field counterField, Str:Obj? filter, Int incBy := 1)
Do an atomic increment/decrement on a field It's a bit of a hack, but we can't simply use a fanlink object since we would have to have a
$inc
named field, which is an illegal field name ... so just building that by hand.Note that incBy can be negative for doing an atomic decrease.
- doc
static Str:Obj? doc(Str name, Obj? val)
Just syntax sugar for manually creating mongo docs
- mongoDocName
static Str mongoDocName(Type type)
Using same naming convention as fanlink
- recentPods
static List recentPods(DB db, Int nbItems := 6)
Most recenty updated public pods Because we bypass fanlink we get a plain list as the result
- remove
static Void remove(DB db, Type type, Str:Obj? filter)
remove an item from the db
- runFanrQuery
static PodSpec[] runFanrQuery(DB db, Query q, Int numVersions)
Take a standard fan query and build a mongo query object from it This should be much faster than fetching all and filtering locally as done by query.include
right now it's not very optimized, much of the filtering is done here rather tha building the exact mongo query to get what we need ... but that's would be lots of work and version would be tricky.
- searchPods
static List searchPods(DB db, Str query)
Search pod names and summary (can use patterns) Because we bypass fanlink we get a plain list as the result
- topPods
static List topPods(DB db, Int nbItems := 10)
Most downloaded public pods Because we bypass fanlink we get a plain list as the result