Skip to content

Commit

Permalink
add remove function (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlmn committed Jun 21, 2022
1 parent f8b94ce commit 3d0da77
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/db/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export const mergeBlock = (db: RxDatabase, doc: Partial<types.Block> & { id: typ

export const mergePage = (db: RxDatabase, doc: Partial<types.Page> & { id: types.BlockID }) => merge(db, doc);

export const remove = (db: RxDatabase, id: types.BlockID) =>
db.docs
.findOne({
selector: {
id: { $eq: id },
document_type: { $in: ["block", "page"] },
},
})
.remove();

export const upsertDocs = async (db: RxDatabase, docs: types.DbDocument[]): Promise<RxDatabase> => {
log.debug(`upserting docs`, docs);
return await Promise.all(docs.map((d) => db.docs.atomicUpsert(d))).then((ds) => {
Expand Down

0 comments on commit 3d0da77

Please sign in to comment.