GoodDB
    Preparing search index...
    • Filter values in an array stored in a key

      Parameters

      • this: GoodDB
      • key: string

        The key of the array to filter

      • callback: (value: any, index: number, obj: any[]) => unknown

        The callback filter function to use

      • Optionaloptions: methodOptions

        The options to use

      Returns any[] | Promise<any[]>

      A promise if the driver is async, otherwise an array of filtered values

      const db = new GoodDB(new JSONDriver({
      path: './database.json'
      }));

      db.filter('users', (user) => user.age > 18);
      const db = new GoodDB(new MongoDBDriver({
      uri: "..."
      }));

      await db.connect();

      await db.filter('users', (user) => user.age > 18);