@pbvision/firestore-orm 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/models.js +8 -2
package/package.json
CHANGED
package/src/models.js
CHANGED
|
@@ -403,7 +403,12 @@ export class Model {
|
|
|
403
403
|
pieces.push(stableStringify(givenValue))
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
|
|
406
|
+
|
|
407
|
+
// ` becomes `` (because we're going to use ` as an escape sequence)
|
|
408
|
+
// / becomes `F (because / is not allowed in Firestore doc keys)
|
|
409
|
+
const ret = pieces.join('\0')
|
|
410
|
+
const escaped = ret.replace(/`/g, '``').replace(/[/]/g, '`F')
|
|
411
|
+
return escaped
|
|
407
412
|
}
|
|
408
413
|
|
|
409
414
|
/**
|
|
@@ -418,7 +423,8 @@ export class Model {
|
|
|
418
423
|
*/
|
|
419
424
|
static __decodeCompoundValue (keyOrder, val) {
|
|
420
425
|
// Assume val is otherwise a string
|
|
421
|
-
const
|
|
426
|
+
const unescaped = val.replace(/`F/g, '/').replace(/``/g, '`')
|
|
427
|
+
const pieces = unescaped.split('\0')
|
|
422
428
|
if (pieces.length !== keyOrder.length) {
|
|
423
429
|
throw new InvalidFieldError(
|
|
424
430
|
'KEY', 'failed to parse key: incorrect number of components')
|