Super Fast Cross Platform Database for Flutter & Web Apps
🚧 Very unstable and not ready for serious usage 🚧
Quickstart • Documentation • Examples • Support & Ideas • Pub.dev
Isar [ee-zahr]:
- River in Bavaria, Germany.
- Database that will make your life easier.
dependencies: isar: any isar_flutter: any # contains the binariesdev_dependencies: isar_generator: any build_runnder: any
@Collection() class Post with IsarObject {@ObjectId() // implicit unique index String uuid;
@Index(stringType: StringIndexType.words, caseSensitive: false) // Search index String title;
List comments }
All basic crud operations are available via the IsarCollection.
final newPost = Post() ..id = uuid() ..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 });
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 search index .limit(10) .findAll()
final postsWithFirstCommentOrTitle = isar.posts .where() .sortedById() // use implicit ObjectId index .filter() .commentsAnyEqualTo('first', caseSensitive: false) .or() .titleEqualTo('first') .findAll();
With Isar you can watch Collections, Objects or Queries. A watcher is notified after a transactions commits succesfully and the target actually changes. Watchers can be lazy and not reload the data or they can be non-lazy and fetch the new results in background.
Stream collectionStream = isar.posts.watch(lazy: true);Stream> queryStream = databasePosts.watch(lazy: false);
queryStream.listen((newResult) { // do UI updates })
Copyright 2021 Simon LeierLicensed 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.