async deleteOne(
    filter,
  ) {
    const files = Deno.readDirSync(
      Deno.realPathSync(`${this.sabr.directoryPath}${this.name}`),
    );
    for (const file of files) {
      if (!file.name || !file.isFile) continue;
      try {
        // Substring remove the file type `.json` from file.name
        const name = file.name.substring(0, file.name.lastIndexOf("."));
        const json = await this.get(name);
        if (json) {
          if (typeof filter === "function") {
            return this.delete(name);
          } else {
            // deno-lint-ignore no-explicit-any
            const invalid = Object.keys(filter).find((key) =>
              json[key] !== filter[key]
            );
            if (!invalid) return this.delete(name);
          }
        }
      } catch (error) {
        this.sabr.error(
          `[Sabr Error: deleteMany]: Unable to read file ${this.sabr.directoryPath}${this.name}/${file.name}`,
          error,
        );
      }
    }
  }
/** Deletes one document in a table that match a filter */
Deletes one document in a table that match a filter
Deletes one document in a table that match a filter
async deleteOne(
    filter,
  ) {
    const files = Deno.readDirSync(
      Deno.realPathSync(`${this.sabr.directoryPath}${this.name}`),
    );
    for (const file of files) {
      if (!file.name || !file.isFile) continue;
      try {
        const name = file.name.substring(0, file.name.lastIndexOf("."));
        const json = await this.get(name);
        if (json) {
          if (typeof filter === "function") {
            return this.delete(name);
          } else {
            const invalid = Object.keys(filter).find((key) =>
              json[key] !== filter[key]
            );
            if (!invalid) return this.delete(name);
          }
        }
      } catch (error) {
        this.sabr.error(
          `[Sabr Error: deleteMany]: Unable to read file ${this.sabr.directoryPath}${this.name}/${file.name}`,
          error,
        );
      }
    }
  }
async deleteOne ( filter , ) { const files = Deno . readDirSync ( Deno . realPathSync ( ` ${ this . sabr . directoryPath } ${ this . name } ` ) , ) ; for ( const file of files ) { if ( ! file . name || ! file . isFile ) continue ; try { const name = file . name . substring ( 0 , file . name . lastIndexOf ( "." ) ) ; const json = await this . get ( name ) ; if ( json ) { if ( typeof filter === "function" ) { return this . delete ( name ) ; } else { const invalid = Object . keys ( filter ) . find ( ( key ) => json [ key ] !== filter [ key ] ) ; if ( ! invalid ) return this . delete ( name ) ; } } } catch ( error ) { this . sabr . error ( ` ${ this . sabr . directoryPath } ${ this . name } ${ file . name } ` , error , ) ; } } }
Deletes one document in a table that match a filter
Deletes one document in a table that match a filter
// Substring remove the file type `.json` from file.name // deno-lint-ignore no-explicit-any