We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7c48e94 commit 36daf85Copy full SHA for 36daf85
shared-libs/cht-datasource/src/local/libs/doc.ts
@@ -175,3 +175,19 @@ export const fetchAndFilterUuids = (
175
limit
176
);
177
};
178
+
179
+/** @internal */
180
+const createDoc = async(db: PouchDB.Database, data:Record<string, unknown>) : Promise<Doc> => {
181
+ const {id, ok} = await db.post(data);
182
+ if (!ok) {
183
+ throw new Error('Error creating document.');
184
+ }
185
+ const createdDoc = (db as PouchDB.Database<Doc>)
186
+ .get(id)
187
+ .then(doc => {
188
+ return doc;
189
+ }).catch(() => {
190
+ throw new Error('Failed to fetch created document.');
191
+ });
192
+ return createdDoc;
193
+};
0 commit comments