realm-dart icon indicating copy to clipboard operation
realm-dart copied to clipboard

Implement filtering like in C#

Open mohachouch opened this issue 2 years ago • 16 comments

Description

Hello,

The C# framework allows filtering using the property name directly. In dart, the filter is carried out in character string.

var cars = realm.all<Car>().query('make == "Tesla"');

var cars = realm.All<Dog>().Where(car => car.Make == "Tesla");

The C# way is much more interesting, it allows autocompletion, avoid bugs.

Is it planned to implement the same way as in C# ?

Thanks you very much. Mohamed

How important is this improvement for you?

Would be a major improvement

mohachouch avatar Nov 03 '22 13:11 mohachouch

Hi, We have plans of doing something similar to .NET thanks for the feedback.

blagoev avatar Nov 03 '22 13:11 blagoev

Thank you @blagoev

Do you have more details on the roadmap.

We would like to migrate to flutter (from Xamarin) for a project on a large company in France.

We would like to use Realm for our local database but we have two blocking points:

  • Realm flutter is still in beta (when the first release is planned)
  • and the method of filtering

Thanks

mohachouch avatar Nov 03 '22 13:11 mohachouch

I can't share specific timelines but I can assure you the team is working hard to get there. Will be glad to hear more about what features are you missing from the beta. We call it a beta mostly cause we are still missing some features compared to the rest of the Realm SDKs.

blagoev avatar Nov 03 '22 14:11 blagoev

Hi, We have just released a Release Candidate version. Hope that you could try and that it will work for the French project you wanted to start on.

cheers

blagoev avatar Nov 05 '22 12:11 blagoev

Thank you for this wonderful work

mohachouch avatar Nov 08 '22 22:11 mohachouch

Hi,

Any update for this feature ?

Thanks

mohachouch avatar Jan 30 '23 06:01 mohachouch

@bmunkholm Hello, do you have an estimated date? This feature is for me a necessity to use realm in my company.

mohachouch avatar Feb 16 '23 20:02 mohachouch

Can you clarify why this is a necessity? I mean, it's definitely nicer to use expressions rather than strings, but I wouldn't view this as a dealbreaker - as far as I can tell, there's no database library for dart that offers LINQ-like syntax for querying.

nirinchev avatar Feb 16 '23 23:02 nirinchev

Thank you for your reply. Here are the reasons why I think this is a "major" feature.

  • Productivity: Autocompletion will automatically offer the user the properties of a class.

  • Maintenance: In case of variable name change or to know where a variable is used

  • Bug: avoid syntax errors, forget a letter or reverse

In addition, some competitors already offer this feature: SQL ORM (Based on sqlite): https://pub.dev/packages/sqfentity https://pub.dev/packages/drift

NO SQL ORM: https://pub.dev/packages/hive https://pub.dev/packages/objectbox

Thanks

mohachouch avatar Feb 17 '23 09:02 mohachouch

Oh, I think I understand - it's a bit of technicality, but it threw me off initially - those packages are not using expressions for the queries, but rather the builder pattern. That should be significantly easier to implement if we decided to go that route, so I guess something to consider.

nirinchev avatar Feb 17 '23 10:02 nirinchev

Dart not allowing to return the name of a property (nameof in C#). I think it will be difficult to do everything in expression. But first of all to be able to have the list of properties (ex: nameKey for name) in the generated class will be a good start.

mohachouch avatar Feb 17 '23 14:02 mohachouch

I think the first method with expressions like in c# needs an update side dart

mohachouch avatar Feb 17 '23 14:02 mohachouch

Any movement on this?

dotjon0 avatar Oct 31 '23 00:10 dotjon0

Not in the short term, no. Since this is more of a nice-to-have than net new functionality, it's lower priority than features we're missing, such as geospatial support or ability to call mongodb API directly.

nirinchev avatar Oct 31 '23 10:10 nirinchev

I think this is an essential feature @nirinchev . As part of our project we choose another database because of the lack of this feature.

mohachouch avatar Nov 01 '23 17:11 mohachouch

That's fair enough. At the end of the day, each database will have strong and weak sides and everyone should choose the one that fits their use case best. Strongly typed query API is something we do want to do eventually, but we haven't seen enough commercial interest to justify the investment at this point. If someone from the community would like to pick that up, we'd be happy to assist.

nirinchev avatar Nov 01 '23 21:11 nirinchev