diff --git a/lib/mongo-object.js b/lib/mongo-object.js index a93309e..51c6e14 100644 --- a/lib/mongo-object.js +++ b/lib/mongo-object.js @@ -671,16 +671,17 @@ export default class MongoObject { /* STATIC */ - /* Takes a specific string that uses mongo-style dot notation - * and returns a generic string equivalent. Replaces all numeric - * "pieces" with a dollar sign ($). + /* Takes a specific string that uses any mongo-style positional update + * dot notation and returns a generic string equivalent. Replaces all numeric + * positional "pieces" (e.g. '.1') or any other positional operator + * (e.g. '$[]') with a dollar sign ($). * * @param {type} name * @returns {String} Generic name. */ static makeKeyGeneric(key) { if (typeof key !== 'string') return null; - return key.replace(/\.[0-9]+(?=\.|$)/g, '.$'); + return key.replace(/\.([0-9]+|\$\[.*\])(?=\.|$)/g, '.$'); } /** Takes a string representation of an object key and its value