2021-03-26 20:36:55 +01:00
2021-03-26 00:48:12 +01:00
2021-03-26 20:32:00 +01:00
2021-01-10 01:13:08 +01:00
2021-03-26 00:48:12 +01:00
2021-01-07 14:59:38 +01:00
2021-03-26 20:36:55 +01:00
2021-02-07 22:14:29 +01:00

Isar Database

🚧 Very unstable and not ready for serious usage 🚧

Quickstart • Documentation • Examples • Support & Ideas • Pub.dev

Isar [ee-zahr]:

  1. River in Bavaria, Germany.
  2. Database that will make your life easier.

Features

  • ⚡️ Launch your app instantly no matter how much data you have
  • 📈 Highly scalable from hundreds to tens of thousands of records
  • 😎 Lazy loaded. Only load data when you need it
  • 🔎 Full-text search. Make searching fast and fun
  • 📱 Multiplatform. iOS, Android, Desktop and the web (soon™)
  • 💙 Made for Flutter. Easily use it in your Flutter app
  • 🧪 ACID semantics. Rely on consistency
  • ⏱ Asynchronous. Parallel query operations & multi-isolate support
  • ⚠️ Static typing. Compile-time checked and autocompleted queries
  • 🔒 Strong encryption. Optional authenticated AES-256 GCM encryption

Add to pubspec.yaml

dependencies:
  isar: <current_version>
  isar_flutter_libs: <current_version> # contains the binaries
  isar_connect: <current_version> # if you want to use the Isar Inspector

dev_dependencies:
  isar_generator: <current_version>
  build_runner: any

Isar Inspector

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

Schema definition

@Collection()
class Post {
  int? id; // auto increment id

  @Index(indexType: IndexType.words, caseSensitive: false) // Search index
  String title;

  List<String> comments
}

CRUD operations

All basic crud operations are available via the IsarCollection.

final newPost = Post()
  ..id = uuid.v4()
  ..title = 'Amazing new database'
  ..comments = ['First'];

await isar.writeTxn((isar) {
  await isar.posts.put(newPost); // insert
});

final existingPost = await isar.get(newPost.id); // get

await isar.writeTxn((isar) {
  await isar.posts.delete(existingPost.id); // delete
});

Queries

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

final isar = await openIsar();

final databasePosts = isar.posts
  .where()
  .titleWordBeginsWith('DaTAb') // use case insensitive search index
  .limit(10)
  .findAll()

final postsWithFirstCommentOrTitle = isar.posts
  .where()
  .filter()
  .commentsAnyEqualTo('first', caseSensitive: false)
  .or()
  .titleEqualTo('first')
  .findAll();

You can easily define relationships between objects. In Isar they are called links and backlinks:

@IsarCollection()
class Teacher {
    int id;

    String subject;

    @Backlink(to: 'teacher')
    final students = IsarLinks<Student>();
}

@IsarCollection()
class Student {
    int id;

    String name;

    final teacher = IsarLink<Teacher>();
}

Watchers

With Isar, you can watch Collections, Objects, or Queries. A watcher is notified after a transaction commits successfully and the target actually 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.posts.watch(lazy: true);

Stream<List<Post>> queryStream = databasePosts.watch(lazy: false);

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

License

Copyright 2021 Simon Leier

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.
S
Description
Extremely fast, easy to use, and fully async NoSQL database for Flutter
Readme Apache-2.0
18 MiB
Languages
Dart 71%
Rust 22.1%
TypeScript 2.4%
C++ 1.7%
CMake 1.1%
Other 1.6%