@jota-one/drosse
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -124,2 +124,7 @@ const Loki = require('lokijs') | ||
query: { | ||
list(collection) { | ||
const coll = db.getCollection(collection) | ||
return coll.data.map(clean()) | ||
}, | ||
getRef(refObj, dynamicId) { | ||
@@ -174,2 +179,7 @@ const { collection, id: refId } = refObj | ||
insert(collection, ids, payload) { | ||
const coll = db.getCollection(collection) | ||
return coll.insert(lodash.cloneDeep({ ...payload, DROSSE: { ids } })) | ||
}, | ||
update: { | ||
@@ -185,4 +195,33 @@ byId(collection, id, newValue) { | ||
}, | ||
subItem: { | ||
append(collection, id, subPath, payload) { | ||
const coll = db.getCollection(collection) | ||
coll.findAndUpdate({ 'DROSSE.ids': { $contains: id } }, doc => { | ||
if (!lodash.get(doc, subPath)) { | ||
lodash.set(doc, subPath, []) | ||
} | ||
lodash.get(doc, subPath).push(payload) | ||
}) | ||
}, | ||
prepend(collection, id, subPath, payload) { | ||
const coll = db.getCollection(collection) | ||
coll.findAndUpdate({ 'DROSSE.ids': { $contains: id } }, doc => { | ||
if (!lodash.get(doc, subPath)) { | ||
lodash.set(doc, subPath, []) | ||
} | ||
lodash.get(doc, subPath).unshift(payload) | ||
}) | ||
}, | ||
}, | ||
}, | ||
remove: { | ||
byId(collection, id) { | ||
const coll = db.getCollection(collection) | ||
const toDelete = coll.findOne({ 'DROSSE.ids': { $contains: id } }) | ||
return toDelete && coll.remove(toDelete) | ||
}, | ||
}, | ||
} | ||
} |
{ | ||
"name": "@jota-one/drosse", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Mock your backend the right way.", | ||
@@ -5,0 +5,0 @@ "main": "app/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68706
64
1353