β οΈ This repository is a fork of the original project, focusing primarily on bug fixes and small updates for version 3. Our objective is to enhance the stability and reliability of the codebase while implementing minor improvements to refine the user experience. See details below on how to use this community fork.
Quickstart β’ Documentation β’ Sample Apps β’ Support & Ideas β’ Pub.dev
- River in Bavaria, Germany.
- Crazy fast NoSQL database that is a joy to use.
- π 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 ππ
Holy smokes you're here! Let's get started on using the coolest Flutter database out there...
isar_version: &isar_version 3.1.8 # define the version to be used
dependencies:
isar:
version: *isar_version
hosted: https://pub.isar-community.dev/
isar_flutter_libs: # contains Isar Core
version: *isar_version
hosted: https://pub.isar-community.dev/
dev_dependencies:
isar_generator:
version: *isar_version
hosted: https://pub.isar-community.dev/
build_runner: any
part 'email.g.dart';
@collection
class Email {
Id id = Isar.autoIncrement; // you can also use id = null to auto increment
@Index(type: IndexType.value)
String? title;
List<Recipient>? recipients;
@enumerated
Status status = Status.pending;
}
@embedded
class Recipient {
String? name;
String? address;
}
enum Status {
draft,
pending,
sent,
}
final dir = await getApplicationDocumentsDirectory();
final isar = await Isar.open(
[EmailSchema],
directory: dir.path,
);
final emails = await isar.emails.filter()
.titleContains('awesome', caseSensitive: false)
.sortByStatusDesc()
.limit(10)
.findAll();
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.
All basic crud operations are available via the IsarCollection
.
final newEmail = Email()..title = 'Amazing new database';
await isar.writeTxn(() {
await isar.emails.put(newEmail); // insert & update
});
final existingEmail = await isar.emails.get(newEmail.id!); // get
await isar.writeTxn(() {
await isar.emails.delete(existingEmail.id!); // delete
});
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()
With Isar database, 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.emails.watchLazy();
Stream<List<Post>> queryStream = importantEmails.watch();
queryStream.listen((newResult) {
// do UI updates
})
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.
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.
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 |
Peyman |
Simon Leier |
Ura |
blendthink |
mnkeis |
nobkd |
Copyright 2022 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.