@pbvision/firestore-orm 0.0.24 → 0.0.26
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/context.js +16 -3
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -678,7 +678,16 @@ function parseFirestoreError (err) {
|
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
|
|
681
|
+
// production Firestore names the document's full resource path, e.g.
|
|
682
|
+
// "Document already exists: projects/p/databases/(default)/documents/Type/id"
|
|
683
|
+
const PRODUCTION_ALREADY_EXISTS_PATH =
|
|
684
|
+
/Document already exists: projects\/[^/]+\/databases\/[^/]+\/documents\/(.+)$/s
|
|
685
|
+
|
|
681
686
|
function parseFirestoreErrorPath (err) {
|
|
687
|
+
const docPath = PRODUCTION_ALREADY_EXISTS_PATH.exec(err.message)?.[1]
|
|
688
|
+
if (docPath) {
|
|
689
|
+
return splitDocPath(docPath)
|
|
690
|
+
}
|
|
682
691
|
const startIdx = err.message.indexOf('Element {')
|
|
683
692
|
if (startIdx >= 0) {
|
|
684
693
|
const endIdx = err.message.indexOf('}', startIdx)
|
|
@@ -714,9 +723,13 @@ function parseFirestoreErrorPathAlternate (err) {
|
|
|
714
723
|
if (endIdx < startIdx) {
|
|
715
724
|
return
|
|
716
725
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
726
|
+
return splitDocPath(err.message.substring(startIdx + 5, endIdx))
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// "Type/id", with or without a leading slash
|
|
730
|
+
function splitDocPath (path) {
|
|
731
|
+
const pieces = path.replace(/^\//, '').split('/')
|
|
732
|
+
if (pieces.length === 2 && pieces[0] && pieces[1]) {
|
|
720
733
|
return { collection: pieces[0], id: pieces[1] }
|
|
721
734
|
}
|
|
722
735
|
}
|