firestore-meilisearch 0.1.7 → 0.1.9
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/README.md +2 -3
- package/lib/index.js +8 -3
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +17 -3
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -44,12 +44,11 @@ Before installing this extension, you'll need to:
|
|
|
44
44
|
|
|
45
45
|
#### Data import format
|
|
46
46
|
|
|
47
|
-
Documents indexed in Meilisearch must have
|
|
47
|
+
Documents indexed in Meilisearch must have an [unique id](https://docs.meilisearch.com/learn/core_concepts/documents.html#primary-field). Meilisearch uses Firestore's default field: `Document ID` for this purpose, and renames it to`_firestore_id`.
|
|
48
48
|
|
|
49
49
|
**Important:** If your documents contain a field called `_firestore_id`, it will be ignored.
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
If a `GeoPoint` is found without the name `_geo`, it is added as an array.
|
|
51
|
+
If you are using `GeoPoint`, the field should be named `_geo` to be recognized by Meilisearch for [geosearch]((https://docs.meilisearch.com/reference/features/geosearch.html#geosearch)).
|
|
53
52
|
|
|
54
53
|
#### Backfill your Meilisearch data
|
|
55
54
|
|
package/lib/index.js
CHANGED
|
@@ -57,7 +57,10 @@ async function handleAddDocument(documentId, snapshot) {
|
|
|
57
57
|
logs.addDocument(documentId);
|
|
58
58
|
if ((0, validate_1.validateDocumentId)(documentId)) {
|
|
59
59
|
const document = (0, adapter_1.adaptDocument)(documentId, snapshot);
|
|
60
|
-
await index.addDocuments([document], {
|
|
60
|
+
const { taskUid } = await index.addDocuments([document], {
|
|
61
|
+
primaryKey: '_firestore_id',
|
|
62
|
+
});
|
|
63
|
+
firebase_functions_1.logger.info(`Document addition request for document with ID ${documentId} added to task list (task ID ${taskUid}).`);
|
|
61
64
|
}
|
|
62
65
|
else {
|
|
63
66
|
firebase_functions_1.logger.error(`Could not create document with id: ${documentId}. The document id can only contain case-insensitive alphanumeric characters (abcDEF), hyphens (-) or underscores(_).`);
|
|
@@ -75,7 +78,8 @@ async function handleDeleteDocument(documentId) {
|
|
|
75
78
|
try {
|
|
76
79
|
logs.deleteDocument(documentId);
|
|
77
80
|
if ((0, validate_1.validateDocumentId)(documentId)) {
|
|
78
|
-
await index.deleteDocument(documentId);
|
|
81
|
+
const { taskUid } = await index.deleteDocument(documentId);
|
|
82
|
+
firebase_functions_1.logger.info(`Document deletion request for document with ID ${documentId} added to task list (task ID ${taskUid}).`);
|
|
79
83
|
}
|
|
80
84
|
else {
|
|
81
85
|
firebase_functions_1.logger.error(`Could not delete document with id: ${documentId}. The document id can only contain case-insensitive alphanumeric characters (abcDEF), hyphens (-) or underscores(_).`);
|
|
@@ -95,7 +99,8 @@ async function handleUpdateDocument(documentId, after) {
|
|
|
95
99
|
logs.updateDocument(documentId);
|
|
96
100
|
if ((0, validate_1.validateDocumentId)(documentId)) {
|
|
97
101
|
const document = (0, adapter_1.adaptDocument)(documentId, after);
|
|
98
|
-
await index.addDocuments([document]);
|
|
102
|
+
const { taskUid } = await index.addDocuments([document]);
|
|
103
|
+
firebase_functions_1.logger.info(`Document update request for document with ID ${documentId} added to task list (task ID ${taskUid}).`);
|
|
99
104
|
}
|
|
100
105
|
else {
|
|
101
106
|
firebase_functions_1.logger.error(`Could not update document with id: ${documentId}.The document id can only contain case-insensitive alphanumeric characters (abcDEF), hyphens (-) or underscores(_).`);
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -67,7 +67,13 @@ async function handleAddDocument(
|
|
|
67
67
|
logs.addDocument(documentId)
|
|
68
68
|
if (validateDocumentId(documentId)) {
|
|
69
69
|
const document = adaptDocument(documentId, snapshot)
|
|
70
|
-
await index.addDocuments([document], {
|
|
70
|
+
const { taskUid } = await index.addDocuments([document], {
|
|
71
|
+
primaryKey: '_firestore_id',
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
logger.info(
|
|
75
|
+
`Document addition request for document with ID ${documentId} added to task list (task ID ${taskUid}).`
|
|
76
|
+
)
|
|
71
77
|
} else {
|
|
72
78
|
logger.error(
|
|
73
79
|
`Could not create document with id: ${documentId}. The document id can only contain case-insensitive alphanumeric characters (abcDEF), hyphens (-) or underscores(_).`
|
|
@@ -86,7 +92,11 @@ async function handleDeleteDocument(documentId: string): Promise<void> {
|
|
|
86
92
|
try {
|
|
87
93
|
logs.deleteDocument(documentId)
|
|
88
94
|
if (validateDocumentId(documentId)) {
|
|
89
|
-
await index.deleteDocument(documentId)
|
|
95
|
+
const { taskUid } = await index.deleteDocument(documentId)
|
|
96
|
+
|
|
97
|
+
logger.info(
|
|
98
|
+
`Document deletion request for document with ID ${documentId} added to task list (task ID ${taskUid}).`
|
|
99
|
+
)
|
|
90
100
|
} else {
|
|
91
101
|
logger.error(
|
|
92
102
|
`Could not delete document with id: ${documentId}. The document id can only contain case-insensitive alphanumeric characters (abcDEF), hyphens (-) or underscores(_).`
|
|
@@ -110,7 +120,11 @@ async function handleUpdateDocument(
|
|
|
110
120
|
logs.updateDocument(documentId)
|
|
111
121
|
if (validateDocumentId(documentId)) {
|
|
112
122
|
const document = adaptDocument(documentId, after)
|
|
113
|
-
await index.addDocuments([document])
|
|
123
|
+
const { taskUid } = await index.addDocuments([document])
|
|
124
|
+
|
|
125
|
+
logger.info(
|
|
126
|
+
`Document update request for document with ID ${documentId} added to task list (task ID ${taskUid}).`
|
|
127
|
+
)
|
|
114
128
|
} else {
|
|
115
129
|
logger.error(
|
|
116
130
|
`Could not update document with id: ${documentId}.The document id can only contain case-insensitive alphanumeric characters (abcDEF), hyphens (-) or underscores(_).`
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.9'
|