Drop Document
Delete a document from the collection.
Definition
await zkdb
.db(databaseName: string)
.collection(collectionName: string)
.findOne(filter: Record<string, any>)
.drop(): Promise<boolean>;
Parameters
- None
Returns
Promise<boolean>
: Returnstrue
when the document is successfully deleted from the collection. The deletion is immediately effective for queries (document will no longer be found) and will be recorded in the next zero-knowledge proof generation cycle for immutable audit trail on blockchain.
Example
import { ZkDatabase } from 'zkdb';
const zkdb = await ZkDatabase.connect({
userName: "chiro-user",
privateKey: "EKFTciRxyxshZjimay9sktsn7v5PvmC5zPq7q4JnitHUytxUVnFP",
environment: "node",
// This URL is for test environment
url: "https://api.zkdatabase.org/graphql",
});
await zkdb.auth.signIn();
const dbTest = zkdb.db('zkdb_test');
const collection = dbTest.collection('Shirt');
const doc = await collection.findOne({ name: 'Orochi' });
const result = await doc.drop();
console.log('Drop result:', result);
await zkdb.auth.signOut();
Result:
Drop result: true