[ ] Rename MimirIndex to RawMimirIndex? Maybe we could add a type alias and deprecate one?
[ ] TypedMimirIndex (created in macros): class TypedMimirIndex<T> {…}
An adapter around RawMimirIndex that handles JSON conversions
[ ] Macro that defines extension on MimirInstance that has a TypedMimirIndex<ClassName> get classNameIndex for a certain user-defined ClassName
Instead of depending on a JSON package, ideally we can just check for the existence of toMap/toJson and fromMap/fromJson in macros placed on ClassName
[ ] Macro that adds static where method(s) on each user-defined class for easier & type-safe queries (supporting String, number, and boolean).
E.g., for @mimir class Movie {...}, we could have something like Mimir.and([Movie.whereTitleIsEqualTo('Forrest Gump'), Movie.whereYearIsBetween(2000, 2010)]) or Mimir.and([Mimir.where(titleIsEqualTo: 'Forrest Gump'), Mimir.where(yearIsBetween: (2000, 2010))])
Instead of just one where method, which would be nice/concise, I think it would be better to add several functions for each field. Reason being: isBetween requires an and parameter, which cannot be type-safe. Also, multiple methods for each field forces the method use to be checked at compile time instead of runtime (say, if a user specifies both isEqualTo and isGreaterThan inside the same .where())
Actually, revisiting this, perhaps we can make the isBetween field a tuple when records/patterns are supported in Dart 3. Although we will still have the issue where you can have multiple things defined in the same where call, perhaps we can add a few where variants: whereOr & whereAnd, which break down their members into Mimir.or and Mimir.and for convenience.
[ ] Macro that adds SortBy generators for each field
Proposed API: Movie.sortByAsc.title and Movie.sortByDesc.year, for example, would simply return SortBy.asc('title') and SortBy.desc('year')
[ ] Native Assets instead of custom packaging system in flutter_mimir
Note: there will be no extension methods placed on user-defined classes (i.e. create(), updateWith(), delete()) in plain mimir because there is no way to know the associated instance.
While we could add our own _mimirInstance field to user-defined classes, this approach has numerous issues.
flutter_mimir
[ ] Remove re-export of mimir, and update README with so
[ ] Not great to re-export right now anyways, but mimir API bindings rely on a particular binary, so flutter_mimir has to enforce this by including a bundled version.
[ ] defaultMimirInstance macro that adds methods to user-defined classes
[ ] I am inclined to do this as it is super convenient; however, I feel like it might open people up to some anti-patterns (using static members instead of DI)
[ ] Think we can come to good compromise by stating dangers in documentation
[ ] Possible because we can use the defaultInstance directly via Mimir.defaultInstance
If anyone sees this issue, please feel free to chime in on the proposed changes for Dart 3 above! Would be nice to have some feedback from people using the library.
Planned Dart 3 (Macros) Migration
mimir
MimirIndex
toRawMimirIndex
? Maybe we could add a type alias and deprecate one?TypedMimirIndex
(created in macros):class TypedMimirIndex<T> {…}
RawMimirIndex
that handles JSON conversionsextension on MimirInstance
that has aTypedMimirIndex<ClassName> get classNameIndex
for a certain user-definedClassName
toMap
/toJson
andfromMap
/fromJson
in macros placed onClassName
where
method(s) on each user-defined class for easier & type-safe queries (supportingString
,number
, andboolean
).@mimir class Movie {...}
, we could have something likeMimir.and([Movie.whereTitleIsEqualTo('Forrest Gump'), Movie.whereYearIsBetween(2000, 2010)])
orMimir.and([Mimir.where(titleIsEqualTo: 'Forrest Gump'), Mimir.where(yearIsBetween: (2000, 2010))])
where
method, which would be nice/concise, I think it would be better to add several functions for each field. Reason being:isBetween
requires anand
parameter, which cannot be type-safe. Also, multiple methods for each field forces the method use to be checked at compile time instead of runtime (say, if a user specifies bothisEqualTo
andisGreaterThan
inside the same.where()
)isBetween
field atuple
when records/patterns are supported in Dart 3. Although we will still have the issue where you can have multiple things defined in the samewhere
call, perhaps we can add a fewwhere
variants:whereOr
&whereAnd
, which break down their members intoMimir.or
andMimir.and
for convenience.SortBy
generators for each fieldMovie.sortByAsc.title
andMovie.sortByDesc.year
, for example, would simply returnSortBy.asc('title')
andSortBy.desc('year')
flutter_mimir
Note: there will be no extension methods placed on user-defined classes (i.e.
create()
,updateWith()
,delete()
) in plainmimir
because there is no way to know the associated instance. While we could add our own_mimirInstance
field to user-defined classes, this approach has numerous issues.flutter_mimir
defaultMimirInstance
macro that adds methods to user-defined classesdefaultInstance
directly viaMimir.defaultInstance
create()
,updateWith(…)
,delete()
methods plannedcreate()
can probably just callupdateWith(...)
for its implementationsearch()
,searchStream()
,documents
, ... to each class as static as well