isar-community / isar

Extremely fast, easy to use, and fully async NoSQL database for Flutter
https://isar-community.dev
Apache License 2.0
124 stars 14 forks source link

The method 'filter' isn't defined for the type 'IsarCollection' #93

Closed roshanproductions closed 1 week ago

roshanproductions commented 1 month ago

Steps to Reproduce

Build runner ran successfully, but I get the following error on queries:

The method 'filter' isn't defined for the type 'IsarCollection' Try correcting the name to the name of an existing method, or defining a method named 'filter'.

    final downloaderTaskCollection = _isar.downloaderTaskCollections  \\ works upto this line, but following lines produces error
        .filter()
        .mediaIdEqualTo(mediaId)
        .findFirstSync();

Details

vicenterusso commented 1 month ago

can you post your collection class?

roshanproductions commented 1 month ago

Here you go:

import 'package:isar/isar.dart';

part 'downloader_task_collection.g.dart';

@collection
class DownloaderTaskCollection {

  @id
  late int mediaId;

  String? tag;

  String? url;

  String? status;

  String? type;

  String? filename;

  double? progress;

  String? uriData;
}
roshanproductions commented 1 month ago

For some reason, helper methods are not being generated, e.g mediaIdEqualTo() etc..

muhammadarifan commented 1 week ago

Hi, is this resolved ? I also have an error like this today

vicenterusso commented 1 week ago

Try this:

 final downloaderTaskCollection = _isar.downloaderTaskCollections
        .where()
        .mediaIdEqualTo(mediaId)
        .findFirst();
roshanproductions commented 1 week ago
_isar. downloaderTaskCollections
        .where()
        .optional(
          taskId != null,
          (q) => q.idNotEqualTo(taskId!), // this line is not working q.idNotEqualTo
        )

The error is: The method 'idNotEqualTo' isn't defined for the type 'QueryBuilder'