Merge branch 'develop' into feature-nested-sets

This commit is contained in:
ThaumRystra
2023-11-11 10:01:34 +02:00
40 changed files with 562 additions and 394 deletions

View File

@@ -19,6 +19,12 @@ export default function writeScope(creatureId, computation) {
// Mongo can't handle keys that start with a dollar sign
if (key[0] === '$' || key[0] === '_') continue;
// Remove empty objects
if (Object.keys(scope[key]).length === 0) {
delete scope[key];
continue;
}
// Remove large properties that aren't likely to be accessed
delete scope[key].parent;
@@ -29,6 +35,11 @@ export default function writeScope(creatureId, computation) {
}
}
// If this is a creature property, replace the property with a link
if (scope[key]._id && scope[key].type) {
scope[key] = { _propId: scope[key]._id };
}
// Only update changed fields
if (!EJSON.equals(variables[key], scope[key])) {
if (!$set) $set = {};