GithubHelp home page GithubHelp logo

isar / isar Goto Github PK

View Code? Open in Web Editor NEW
3.4K 54.0 276.0 17.33 MB

Extremely fast, easy to use, and fully async NoSQL database for Flutter

Home Page: https://isar.dev

License: Apache License 2.0

Dart 49.93% Shell 0.56% Java 0.06% Swift 0.20% Objective-C 0.06% Ruby 0.31% Kotlin 0.01% C 0.23% CMake 1.43% C++ 2.17% HTML 0.61% Rust 44.42%
flutter dart database cross-platform ios android web isar

isar's Introduction

Isar Database

QuickstartDocumentationSample AppsSupport & IdeasPub.dev

Isar [ee-zahr]:

  1. River in Bavaria, Germany.
  2. Crazy fast NoSQL database that is a joy to use.

⚠️ ISAR V4 IS NOT READY FOR PRODUCTION USE ⚠️
If you want to use Isar in production, please use the stable version 3.

Features

  • 💙 Made for Flutter. Easy to use, no config, no boilerplate
  • 🚀 Highly scalable The sky is the limit (pun intended)
  • 🍭 Feature rich. Composite & multi-entry indexes, query modifiers, JSON support etc.
  • Asynchronous. Parallel query operations & multi-isolate support by default
  • 🦄 Open source. Everything is open source and free forever!

Isar database can do much more (and we are just getting started)

  • 🕵️ Full-text search. Make searching fast and fun
  • 📱 Multiplatform. iOS, Android, Desktop
  • 🧪 ACID semantics. Rely on database consistency
  • 💃 Static typing. Compile-time checked and autocompleted queries
  • Beautiful documentation. Readable, easy to understand and ever-improving

Join the Telegram group for discussion and sneak peeks of new versions of the DB.

If you want to say thank you, star us on GitHub and like us on pub.dev 🙌💙

Quickstart

Holy smokes you're here! Let's get started on using the coolest Flutter database out there...

1. Add to pubspec.yaml

dependencies:
  isar: 4.0.0
  isar_flutter_libs: 4.0.0 # contains Isar Core

dev_dependencies:
  build_runner: any

2. Annotate a Collection

part 'email.g.dart';

@collection
class Email {
  Email({
    this.id,
    this.title,
    this.recipients,
    this.status = Status.pending,
  });

  final int id;

  @Index(type: IndexType.value)
  final String? title;

  final List<Recipient>? recipients;

  final Status status;
}

@embedded
class Recipient {
  String? name;

  String? address;
}

enum Status {
  draft,
  pending,
  sent,
}

3. Open a database instance

final dir = await getApplicationDocumentsDirectory();
final isar = await Isar.open(
  [EmailSchema],
  directory: dir.path,
);

4. Query the database

final emails = isar.emails.where()
  .titleContains('awesome', caseSensitive: false)
  .sortByStatusDesc()
  .limit(10)
  .findAll();

Isar Database Inspector

The Isar Inspector allows you to inspect the Isar instances & collections of your app in real-time. You can execute queries, edit properties, switch between instances and sort the data.

To launch the inspector, just run your Isar app in debug mode and open the Inspector link in the logs.

CRUD operations

All basic crud operations are available via the IsarCollection.

final newEmail = Email()..title = 'Amazing new database';

await isar.writeAsync(() {
  isar.emails.put(newEmail); // insert & update
});

final existingEmail = isar.emails.get(newEmail.id!); // get

await isar.writeAsync(() {
  isar.emails.delete(existingEmail.id!); // delete
});

Database Queries

Isar database has a powerful query language that allows you to make use of your indexes, filter distinct objects, use complex and(), or() and .xor() groups, query links and sort the results.

final importantEmails = isar.emails
  .where()
  .titleStartsWith('Important') // use index
  .limit(10)
  .findAll()

final specificEmails = isar.emails
  .filter()
  .recipient((q) => q.nameEqualTo('David')) // query embedded objects
  .or()
  .titleMatches('*university*', caseSensitive: false) // title containing 'university' (case insensitive)
  .findAll()

Database Watchers

With Isar database, you can watch collections, objects, or queries. A watcher is notified after a transaction commits successfully and the target changes. Watchers can be lazy and not reload the data or they can be non-lazy and fetch new results in the background.

Stream<void> collectionStream = isar.emails.watchLazy();

Stream<List<Post>> queryStream = importantEmails.watch();

queryStream.listen((newResult) {
  // do UI updates
})

Benchmarks

Benchmarks only give a rough idea of the performance of a database but as you can see, Isar NoSQL database is quite fast 😇

If you are interested in more benchmarks or want to check how Isar performs on your device you can run the benchmarks yourself.

Unit tests

If you want to use Isar database in unit tests or Dart code, call await Isar.initializeIsarCore(download: true) before using Isar in your tests.

Isar NoSQL database will automatically download the correct binary for your platform. You can also pass a libraries map to adjust the download location for each platform.

Make sure to use flutter test -j 1 to avoid tests running in parallel. This would break the automatic download.

Contributors ✨

Big thanks go to these wonderful people:


Alexis

Burak

Carlo Loguercio

Frostedfox

Hafeez Rana

Hamed H.

JT

Jack Rivers

Joachim Nohl

Johnson

LaLucid

Lety

Michael

Moseco

Nelson Mutane

Oscar Palomar

Peyman

Simon Choi

Ura

blendthink

mnkeis

nobkd

License

Copyright 2023 Simon Choi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

isar's People

Contributors

7mada123 avatar actions-user avatar allcontributors[bot] avatar blendthink avatar dependabot[bot] avatar devnico avatar escwxyz avatar frostedfox avatar h1376h avatar hafeezrana avatar ham-burger avatar inkomomutane avatar jtplouffe avatar letyletylety avatar maintobias avatar mccrafteriv avatar mnkeis avatar mrclauss avatar myounus96 avatar ndelanou avatar nobkd avatar peterakande avatar peterwvj avatar richard457 avatar shilangyu avatar simc avatar viper-bit avatar voidxhoshi avatar vovcharaa avatar yyong37 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

isar's Issues

Achieve feature parity (or near-parity) on web

Right now, the web repository is empty. We'll need to work on that ;)

We'll need to investigate the practicality of various things with IndexedDB. The main semantic effort will be creating a dexie-esque library which uses automerge CRDTs under the hood.

Download

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Version

  • Platform: iOS, Android, Mac, Windows, Linux, Web
  • Flutter version: [e.g. 1.5.4]
  • Isar version: [e.g. 0.5.0]

Collection name

Hi,

I have an example:

@Collection()
class Series {
  @Id()
  late int id = 0;
  late String name;
  late int? color;
  late String description = '';

  Series();

  Series.fromValue({this.description = '', this.color, required this.name});

  Series.fromJson(Map<String, dynamic> json)
      : id = json['id'],
        name = json['name'],
        color = json['color'],
        description = json['description'] ?? '';
  Map<String, dynamic> toJson() =>
      {'id': id, 'name': name, 'color': color, 'description': description};
}

The generator creates the property seriess because of the plural. It would be cool if there is an option to add a custom name.

Links not working properly

Hi! Two cases bellow:

Collections

import 'package:app/models/teacher.dart';
import 'package:isar/isar.dart';

@Collection()
class Student {
  @Id()
  int? id;

  late String name;

  var teachers = IsarLinks<Teacher>();
}
import 'package:app/models/student.dart';
import 'package:isar/isar.dart';

@Collection()
class Teacher {
  @Id()
  int? id;

  late String subject;

  @Backlink(to: 'teachers')
  var students = IsarLinks<Student>();
}

Case Nr. 1: when updating a collection that contains links - containing links will disappear

final isar = await openIsar();
final student = Student()..name = 'Bob';
final teacher = Teacher()..subject = 'Math';
student.teachers.add(teacher);

await isar.writeTxn((isar) async {
  await isar.students.put(student);
  await student.teachers.saveChanges();
});

print('Student: ' + student.name.toString() + ' Number of teachers: ' + student.teachers.length.toString()); // I/flutter (27822): Student: Bob Number of teachers: 1

final studentToUpdate = await isar.students.get(student.id!);
studentToUpdate!..name = 'Barbie';
await isar.writeTxn((isar) async {
  await isar.students.put(studentToUpdate);
});

final updatedStudent = await isar.students.get(student.id!);
await updatedStudent!.teachers.load();
print('Student: ' + updatedStudent.name.toString() + ' Number of teachers: ' + updatedStudent.teachers.length.toString()); // I/flutter (27822): Student: Barbie Number of teachers: 0

Case Nr. 2: when updating a collection that is a link of another collection - exception is thrown

final isar = await openIsar();
final student = Student()..name = 'Bob';
final teacher = Teacher()..subject = 'Math';
student.teachers.add(teacher);

await isar.writeTxn((isar) async {
  await isar.students.put(student);
  await student.teachers.saveChanges();
});
await student.teachers.load();
final teacherId = student.teachers.first.id!;

print('Student: ' + student.name.toString() + ' Number of teachers: ' + student.teachers.length.toString()); // I/flutter (27822): Student: Bob Number of teachers: 1

final teacherToUpdate = await isar.teachers.get(teacherId);
teacherToUpdate!..subject = 'Biology';
await isar.writeTxn((isar) async {
  await isar.teachers.put(teacherToUpdate); // E/flutter (31277): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: IsarError: DbCorrupted: "Backlink does not exist"
});

Version

  • Platform: Android 10, Xiaomi Mi 9T Lite
  • Flutter version: 2.0.4 • channel stable
  • Dart version: 2.12.2
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0

issue on archive

Issue when i try to archive the iOS build

Screen Shot 2021-04-12 at 1 02 51 PM

Version

  • Platform: iOS
  • Flutter version: 2.0.4
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0

Getting Error : 'The plugin `isar_flutter_libs` doesn't have a main class'

Steps to Reproduce

When I try to pub get , I get this error :


The plugin `isar_flutter_libs` doesn't have a main class defined in C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\isar_flutter_libs-0.1.0\android\src\main\java\dev\isar\isar_flutter_libs\IsarFlutterPlugin.java or C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\isar_flutter_libs-0.1.0\android\src\main\kotlin\dev\isar\isar_flutter_libs\IsarFlutterPlugin.kt. This is likely to due to an incorrect `androidPackage: dev.isar.isar_flutter_libs` or `mainClass` entry in the plugin's pubspec.yaml.
If you are the author of this plugin, fix the `androidPackage` entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.

And the process of getting package terminates.

Code sample
My pubspec.yaml

name: app_2
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  isar: 0.1.0
  isar_flutter_libs: 0.1.0
  koukicons: 2.0.3
  reorderables: 0.3.2
  lorem_cutesum: 1.0.0
  align_positioned: 2.0.0
  simple_animations: 3.0.1
  supercharged: 2.0.0
  animate_do: 2.0.0
  google_fonts: ^1.1.2
  get: ^3.26.0
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  isar_generator: 0.1.0
  build_runnder: 0.1.0

flutter:

  uses-material-design: true

Version
My flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.54.3)
[√] Connected device (3 available)

Create TODO.md

If you want to post a TODO.md, I'd be happy to put some time into this and the other Isar libraries.

I presume that Isar is meant to be "Hive 2.0", essentially Dart bindings to lmdb?

Materialised views and one way sync

Checkout https://github.com/MaterializeInc/materialize.

its 100% rust too

it allows materialised views with mutations pushing out a change event.

there are various things you could use it with Isar to make it reactive.

Have a PostgreSQL dB on the server and create materialised views that get synced with Isar

Or / also embed it with Isar to have the same functionality on the client

Timely data flows are really powerful construct

Marrying the two would allow one way sync with mutations going back to the server and then mutating the materialised view and then creating a change event that is propagated to allow flutter clients that are viewing that materialised view.

UserAdapter not generated on state converters

Steps to Reproduce
I get this error if I generate the isar.g.dart file: Undefined name '_UserAdapter'. Try correcting the name to one that is defined, or defining the name.

Code sample

@Collection()
class Event {
  @Id()
  int? id = 0;
  late String description = '';
  final series = IsarLink<Series>();
  @EventStateConverter()
  late EventState state;

  Event();
  Event.fromValue({this.description = '', this.state = EventState.draft});
  Event.fromJson(Map<String, dynamic> json)
      : id = json['id'] ?? 0,
        description = json['description'] ?? '',
        state = EventState.values[json['state'] ?? 0];

  Map<String, dynamic> toJson() => {'id': id, 'description': description, 'state': state.index};
}

enum EventState { draft, planned, canceled }

class EventStateConverter extends TypeConverter<EventState, int> {
  const EventStateConverter(); // Converters need to have an empty const constructor

  @override
  EventState fromIsar(int index) {
    return EventState.values[index];
  }

  @override
  int toIsar(EventState state) {
    return state.index;
  }
}

Version

  • Platform: Dart only project
  • Flutter version: -
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0

Synchronization

It was clear from the beginning that Isar should support some kind of synchronization capability. Until now I wanted to implement something similar to dexie's sync strategy which provides eventual consistency and requires the users to resolve conflicts themselves. It also can lead to some form of data loss in the event of a conflict.

But it would be really cool if we could design a system that guarantees strong eventual consistency with automatic and deterministic conflict resolution.

Over the past two days, I studied countless papers on the topic and there are multiple ways to achieve this goal. One very promising paper is A Conflict-Free Replicated JSON Datatype.

When the database only contains conflict-free types ("CRDT"s), it would not only be possible to implement synchronization to a server but also using peer to peer connections or a decentralized network, for example, a Bluetooth connection because there is no need for resolving conflicts in a centralized way.

I would love to hear your opinion, ideas, and if possible further writings on the topic.

Since using CRDTs implies very strict rules and detailed tracking of changes, this decision has a great impact on the future development of Isar Core.

Edit:
Naturally with every upside comes a downside. In this case the downside of implementing this proposal it that there will be a small performance impact event when synchronization is disabled. The reason is that we cannot enforce a strict schema any more because different peers may have different versions of the database. This requires using something like Flatbuffer's Flexbuffers to support dynamic schemas.

return id when new record is put

It would be nice if when creating a new record, it's id were returned:

int id = await contacts.put(newContact);

Today this is not possible because put returns void.

I feel that it is standard for api's and databases to offer an ability to have the id returned in some way or other when inserting a new record. Often the entire object is returned.

My use-case: When the user creates a new object, the app should open it's form. So I want to pass the id to the route.

Version

  • Platform: Android
  • Flutter version: 2.2.0-10.1.pre
  • Isar version: 0.4.0

are aggregation queries implemented?

I tried to use the max function as documented.

But I can't find it.

I am not quite sure where it should be as there is no example but I think it should be:

String? lastServerRevAt = await isar.projects
        .where()
        .serverRevAtProperty()
        .max();

So I have resorted to sorting and finding the first:

String? lastServerRevAt = await isar.projects
        .where()
        .sortByServerRevAtDesc()
        .serverRevAtProperty()
        .findFirst();

Am I doing something wrong or are you only just implementing the aggregations?

Failed to load dynamic library

Hi,
unable to load the library on windows. I am getting:

flutter: Invalid argument(s): Failed to load dynamic library (126)
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: IsarError: Could not initialize IsarCore library. If you create a Flutter app, make sure to add isar_flutter_libs to your dependencies. Isar does not support 32-bit processors so make sure that your device / emulator has a 64-bit processor.
#0      initializeIsarCore
package:isar/…/native/isar_core.dart:56
#1      openIsar
package:isardb/isar.g.dart:39

Version

  • Platform: Android, Windows 64 bit,
  • Flutter version: [2.0.4]
  • Isar version: [0.2.0]
  • Isar flutter lib version: [0.2.0]
  • Isar Generator version: [0.2.0]

Should I download the library manually? if yes what path should it be on windows.

IOS12

Steps to Reproduce
Please describe exactly how to reproduce the problem you are running into.

Code sample

Provide a few simple lines of code to show your problem.

Version

  • Platform: iOS, Android, Mac, Windows, Linux, Web
  • Flutter version: [e.g. 1.5.4]
  • Isar version: [e.g. 0.5.0]
  • Isar Generator version: [e.g. 0.5.0]

"More than one property annotated with @Id()" when inhereting from base class.

Steps to Reproduce

declare a base class:

abstract class BaseModel {
  @Id()
  int? isar_id;
}

and then a class that inherets from it:

@collection()
class TestModel extends BaseModel {}

this fails to generate with:

More than one property annotated with @Id().
package:fe/data_classes/isar/test_model.dart:7:7
  ╷
7 │ class TestModel extends BaseModel {
  │       ^^^^^^^^^
  ╵

pubspec.yaml:

  isar: ^0.4.0
  isar_flutter_libs: ^0.4.0

dev_deps:
  isar_generator: ^0.4.0

extra details
seems to be no way to work around without sacraficing boilerplate; even when implement instead of extend, this issue still exists.

Ideally, I'd like to create a base class with @id and @Index for two properties and have the rest of my models inheret from it, as literally all of my models follow the same pattern.

Thanks!

How to properly update links in collection

Steps to reproduce
I have two simple collections, like in the docs: Student, Teachers
Student have field teachers of links to teachers.
I want to have simple form where i can edit Student and his teachers at one.
How to properly save changed teachers (new ones and some edited) along with student edit?

Simplified code

@Collection class Student { 
 String name;
 @IsarLinks teachers = IsarLinks<Teacher>();
}

@Collection class Teacher {
 String name;
}

final student = await isar.students.get(1);
await student.teachers.load();

student.name = 'Luke';
student.teachers.elementAt(1).name = 'Joe';
student.teachers.add(Teacher()..name='April');

isar.writeTxn((isar) async {
 await isar.students.put(student);
 await student.teachers.saveChanges();
 // How to save changed student, added teacher and changed teacher?
};

Issue
I expected that the solution above would work, but no somehow existing teachers always dissapears from the student. They remain in the db (I can query for them explicitly), but newly loaded (refreshed) student only contains the newly added teacher.

I've tried different combinations of what to when save (clearing teachers from student and adding again and more). Closest was when I manually copied every teacher to a new object, clear student teachers and and new copies of teachers, which is not optimal 😀 I see in code, that saveChanges() probably only applies to newly added/removed items in list, I would be ok that existing teachers wasn't updated, but why are the removed from studen teachers list?

Am I missing something?

Version

  • Platform: Windows
  • Flutter version: 2.0.1
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0

Dynamic location of the generated file "isar.g.dart"

Currently when "flutter pub run build_runner build" is executed, the file isar.g.dart is generated in the LIB folder. This works fine, but when working under some architecture such as ddd, each file has to be placed within a corresponding folder to be able to respect the principles of architecture.

Currently I have manually moved the file isar.g.dart to the corresponding folder, for example:

From
lib -> isar.g.dart

To
lib -> shared -> infrastructure -> isar -> isar.g.dart

The problem comes when there are many Isar domains, I have to re-import all of them.

image

The solution could be, maybe a parameter can be passed when generating the file isar.g.dart, or maybe put the configuration in the file 'pubspect.yaml' and be able to configure some parameters, for example:

...
...
isar:
  path: shared/infrastructure/isar/ #default /
...
...

I come from Hive, and the truth is that I am very happy with all the improvements that Isar brings 😀

Happy Codding 💛

Unique Columns?

Many database solutions (read: all) have a way to make a column a "unique" column. I'd like to do this in Isar too.

Describe the solution you'd like
Perhaps an @Unique tag on a field that perhaps just performs a query by that field and if it already exists throws an error?

Describe alternatives you've considered
I've been literally doing the previous in my repository - Something like this:

class GroupRepository {
  Future<void> addOne(Group group) async {
    if (await _isar.groups.where().filter().idEqualTo(group.id).findFirst() !=
        null) {
      throw NonUniqueException();
    }

    await _isar.writeTxn((isar) async {
      await isar.groups.put(group);
    });
  }
}

I should clarify that I know that the PK column is unique - but, I'm using uuid's in my database and so my model has two Id's: isar_id and id, the latter being a Uuid.

It'd be helpful to remove this boilerplate by having an @Unique flag on a field that doesn't allow inserts if this already exists.

Thanks, and thanks for the awesome package :)

no openIsar on dart project

Steps to Reproduce

I tried isar in a dart project (not Flutter), so i only included the isar dep and noticed that openIsar was not defined.

Code sample

import 'package:isar/isar.dart';

void main(List<String> args) async {
  // openIsar is not defined
  final isar = await openIsar();
}

Version

  • Platform: Mac
  • Flutter version: 2.0.2
  • Isar version: 0.1.0
  • Isar Generator version: NA

Pure Dart support

I just played around with the current state and noticed that the generator imports Flutter packages, specifically path_provider and flutter even though my project doesn't depend on isar_flutter.

Is pure Dart support planned? That's one of the great things about Hive that I would like to see continued here if possible.

Feature / Idea collection

  • Conflict free sync #2
  • Relationship support (how to do it with IndexedDB?)
  • Offline first
  • Peer-to-peer change distribution
  • Schemaless?
  • CloudKit integration
  • Firebase integration

mismatch version isar connect and isar

Because every version of isar_connect depends on isar 0.2.0 and map_app depends on isar ^0.4.0, isar_connect is forbidden.
So, because map_app depends on isar_connect any, version solving failed.
pub get failed (1; So, because map_app depends on isar_connect any, version solving failed.)

isar_generator is incompatible with multipule packages.

Steps to Reproduce

installing the following packages:

  • dependencies:
    freezed_annotation: ^0.14.1
    isar: ^0.1.0
    isar_flutter: ^0.1.0

  • dev_dependencies:
    build_runner: ^1.12.2
    freezed: ^0.14.1+1
    isar_generator: ^0.1.0
    json_serializable: ^4.0.2

Error sample
This is the error message i get:

Because every version of isar_generator depends on freezed_annotation ^0.12.0 and tdd_null_safe depends on freezed_annotation ^0.14.1, isar_generator is forbidden.

and if change the dependencies version of [freezed, freezed_annotation, json_serializable] to any,
i get this error message:

Because every version of isar_generator depends on glob ^1.1.0 and build_runner >=1.11.2 depends on glob ^2.0.0, isar_generator is incompatible with build_runner >=1.11.2.

and finnaly if i change build_runner version to any, i get this error message:

Because every version of isar_generator depends on dartx ^0.5.0 which depends on crypto ^2.1.0, every version of isar_generator requires crypto ^2.1.0.

And because universal_io >=2.0.0 depends on crypto ^3.0.0, isar_generator is incompatible with universal_io >=2.0.0.

i learned about this database on hive's github issues, so i wanted to give it a try, but alas i got the same errors that hive currently has, i know that almost all the generator dependent packages are having a problem fixing the compatibility issues.. so good luck on fixing it, and i wish you all the best, the data base does look promising and i can't wait to start using it.

Version

  • Platform: Android, Windows.
  • Flutter version: 2.0.3
  • Isar version: 0.1.0
  • Isar Generator version: 0.1.0

Maybe Flatbuffers as binary encoder

Hi @leisim,

it is nice to see, that the successor of Hive is finally coming to life. Recently, I was dealing a lot with serialization and ultimately I came across flatbuffers. It seems like, that flatbuffers picks up momentum.

What are your thought on flatbuffers as the serialization format instead of an own implementation? The main benefit I see is that it does not require to deserialize the buffer and can read the values out of it directly. There are implementations of it in various languages also Dart and TypeScript (for Isar Web).

You would get the very performant read of lmdb and then zero deserializing with flatbuffers.

I have not done any testing, but I will do it with a hive fork and see if I can make it work.

Isar generation when collections are in multiple dart packages

When there are multiple packages with a set of collections each, for a single isar instance, we have to manually merge the generated isar code from each of the packages

There should be a way to tell the code generator to consider the generated isar code from other packages.

Desktop support

Do you plan to add support for Windows/Linux/Mac to Isar? This seems like a good fit for a project I'm planning but it would need to have desktop support. You mention that it will be multiplatform in the README, but only mention Android, iOS and Web.

Isar Inspector - Cross platform

Is your feature request related to a problem? Please describe.
I have no mac :(

Describe the solution you'd like
It would be cool if there is an option to run the isar inspector on linux and windows.

Describe alternatives you've considered

Version

  • Platform: Windows 10, Linux(, Web)

.save and .delete methods do not exist

I have seen a number of things that though documented are not implemented yet.

I have so far successfully used these methods to edit data:

  • isar.projects.put(project) to create a new project
  • isar.projects.delete(id) to delete a project

I have not managed to use:

  • project.delete()
  • project.save()

The reason is: these two methods do not exist when I query a project, for instance like this: isar.projects.get(id). The returned object does contain all the variables defined in the model though.

So the quick question is: Have these methods been implemented?
The longer one is (and maybe I need to show some more code for that): What needs to happen for those methods to exist?

Bad state: No element. (final properties not supported)

Hi

I'm getting this error when i run the build_runner, i don't know if I'm doing something wrong here, or there's an issue.

Error log sample

[SEVERE] isar_generator:resolver on lib/app/data/models/product/product_model.dart:

Bad state: No element
dart:collection                                       ListMixin.firstWhere
package:isar_generator/src/isar_analyzer.dart 297:33  IsarAnalyzer.analyzeObjectIndex
package:isar_generator/src/isar_analyzer.dart 91:21   IsarAnalyzer.generateObjectInfo
package:isar_generator/src/isar_analyzer.dart 26:21   IsarAnalyzer.build.<fn>
dart:core                                             Iterable.toList
package:isar_generator/src/isar_analyzer.dart 27:10   IsarAnalyzer.build

Steps to Reproduce
Product_model.dart

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:isar/isar.dart';

import '../../../domain/entities/product.dart';
import '../product_color/product_color_model.dart';

part 'product_model.g.dart';

@Collection()
class ProductModel extends Product {
  @Id()
  final int? id;
  final String? brand;
  @Index(indexType: IndexType.words, caseSensitive: false)
  final String? name;
  final String? price;
  final String? priceSign;
  final String? currency;
  final String? imageLink;
  final String? productLink;
  final String? websiteLink;
  final String? description;
  final double? rating;
  final String? category;
  final String? productType;
  final List<String>? tagList;
  final DateTime? createdAt;
  final DateTime? updatedAt;
  final String? productApiUrl;
  final String? apiFeaturedImage;
  final List<ProductColorModel>? productColors;
  const ProductModel({
    this.id,
    this.brand,
    this.name,
    this.price,
    this.priceSign,
    this.currency,
    this.imageLink,
    this.productLink,
    this.websiteLink,
    this.description,
    this.rating,
    this.category,
    this.productType,
    this.tagList,
    this.createdAt,
    this.updatedAt,
    this.productApiUrl,
    this.apiFeaturedImage,
    this.productColors,
  }) : super(
          id: id,
          brand: brand,
          name: name,
          price: price,
          priceSign: priceSign,
          currency: currency,
          imageLink: imageLink,
          productLink: productLink,
          websiteLink: websiteLink,
          description: description,
          rating: rating,
          category: category,
          productType: productType,
          tagList: tagList,
          createdAt: createdAt,
          updatedAt: updatedAt,
          productApiUrl: productApiUrl,
          apiFeaturedImage: apiFeaturedImage,
          productColors: productColors,
        );

  factory ProductModel.fromJson(Map<String, dynamic> json) =>
      _$ProductModelFromJson(json);
  Map<String, dynamic> toJson() => _$ProductModelToJson(this);
}

which is extended from product

import 'package:equatable/equatable.dart';

import 'product_color.dart';

class Product extends Equatable {
  final int? id;
  final String? brand;
  final String? name;
  final String? price;
  final String? priceSign;
  final String? currency;
  final String? imageLink;
  final String? productLink;
  final String? websiteLink;
  final String? description;
  final double? rating;
  final String? category;
  final String? productType;
  final List<String>? tagList;
  final DateTime? createdAt;
  final DateTime? updatedAt;
  final String? productApiUrl;
  final String? apiFeaturedImage;
  final List<ProductColor>? productColors;

  const Product({
    this.id,
    this.brand,
    this.name,
    this.price,
    this.priceSign,
    this.currency,
    this.imageLink,
    this.productLink,
    this.websiteLink,
    this.description,
    this.rating,
    this.category,
    this.productType,
    this.tagList,
    this.createdAt,
    this.updatedAt,
    this.productApiUrl,
    this.apiFeaturedImage,
    this.productColors,
  });

  @override
  List<Object> get props {
    return [
      id!,
      brand!,
      name!,
      price!,
      priceSign!,
      currency!,
      imageLink!,
      productLink!,
      websiteLink!,
      description!,
      rating!,
      category!,
      productType!,
      tagList!,
      createdAt!,
      updatedAt!,
      productApiUrl!,
      apiFeaturedImage!,
      productColors!,
    ];
  }
}

Version

  • Platform: Windows
  • Flutter version: 2.0.3
  • Isar version: 0.20
  • Isar Generator version: 0.2.0

Error resolving isar_connect 0.4.0 dependencies

I have error adding isar dependencies to project in pubspec.yaml

Code sample

[tranfer_history] flutter pub get
Running "flutter pub get" in tranfer_history...                 
Because tranfer_history depends on isar_connect 0.4.0 which doesn't match any versions, version solving failed.
pub get failed (1; Because tranfer_history depends on isar_connect 0.4.0 which doesn't match any versions, version solving failed.)
exit code 1

Version

  • Platform: iOS, Android, Mac, Windows, Linux, Web
  • Flutter version: 2.0.5
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0

isar_generator fails if a class have a getter method with String return type

Steps to Reproduce
Isar generator gives the error for this class, when I run flutter pub run build_runner build.

The error message:

[INFO] Running build...
[SEVERE] isar_generator:analyzer on lib/db/PlaceVersion.dart:

Bad state: No element
[INFO] Running build completed, took 364ms

If I remove the getQuery method, it is ok.

Code sample

@JsonSerializable()
@Collection()
class PlaceVersion extends Data<PlaceVersion> implements DataInterface<PlaceVersion> {
  @Id()
  int id = 1;
  int region = 0;
  int town = 0;
  int source = 0;
  @JsonKey(name: 'region_town')
  int region_town = 0;
  @JsonKey(name: 'region_module')
  int region_module = 0;
  @JsonKey(name: 'town_module')
  int town_module = 0;
  int version = 0;

  @Ignore()
  @override
  String get getQuery => '/json/place-version';

  @override
  PlaceVersion fromJson(Map<String, dynamic> json) => _$PlaceVersionFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$PlaceVersionToJson(this);
}

Version

  • Platform: Mac
  • Flutter version: 2.0.5
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0
  • build_runner: ^2.0.1

Add a sample project

Can you add a sample flutter project, as I am facing couple of challanges between flutter version/null safety as the library depends on path_provider.

Error:

Because no versions of isar_flutter match >0.0.2 <0.1.0 and isar_flutter 0.0.2 depends on path_provider ^1.6.24, isar_flutter ^0.0.2 requires path_provider ^1.6.24.
And because path_provider >=1.6.17 depends on path_provider_windows ^0.0.4, isar_flutter ^0.0.2 requires path_provider_windows ^0.0.4.
And because every version of path_provider_windows depends on ffi ^0.1.3 and isar >=0.0.1 depends on ffi ^0.2.0-nullsafety.1, isar_flutter ^0.0.2 is incompatible with isar >=0.0.1.
So, because test_db depends on both isar ^0.0.2 and isar_flutter ^0.0.2, version solving failed.
pub get failed (1; So, because test_db depends on both isar ^0.0.2 and isar_flutter ^0.0.2, version solving failed.)

Unable to connect to isar connect

Steps to Reproduce
Simply run the isar inspector
copy the url from your application
press connect

Error:
flutter: isolates/1011297615749035
flutter: ERROR: Unable to connect to VMService
flutter: ext.isar.getVersion: (-32601) Unknown method "ext.isar.getVersion".

Version

  • Platform: iOS, Android, Mac, Windows, Linux, Web
  • Flutter version: stable channel with null safety enable
  • Isar version: 0.2.0
  • Isar Generator version:0.2.0

No automatic imports of Converted types inside Isar.g.dart

Steps to Reproduce
I have a simple Collection with an id and an enum.
I created a TypeConverter and annotated the enum with the converter.
The file isar.g.dart is generated with the converter applied but I have to manually import the enum inside the isar.g.dart (which is not ideal because I have to do it every time the build runner runs)

Code sample

The Collection :

@Collection()
@Name("AppTheme")
class AppThemeEntity {
  int? id;
  @AppThemeConverter()
  late AppThemeId appThemeId;

  AppTheme toDomain() => AppTheme.withId(appThemeId);

  static AppThemeEntity fromDomain(AppTheme appTheme) =>
      AppThemeEntity()..appThemeId = appTheme.id;
}

The TypeConverter :

class AppThemeConverter extends TypeConverter<AppThemeId, int> {
  const AppThemeConverter(); // Converters need to have an empty const constructor

  @override
  AppThemeId fromIsar(int appThemeIdIndex) {
    return AppThemeId.values[appThemeIdIndex];
  }

  @override
  int toIsar(AppThemeId appThemeId) {
    return appThemeId.index;
  }
}

Version

  • Platform: iOS, Android, Mac, Windows, Linux
  • Flutter version: 2.0.6
  • Isar version: 0.4.0
  • Isar Generator version: 0.4.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.