Giter Club home page Giter Club logo

isar's Introduction

Isar Database

🚧 Alpha version - Use with care. 🚧

Quickstart β€’ Documentation β€’ Sample Apps β€’ Support & Ideas β€’ Pub.dev

Isar [ee-zahr]:

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

Features

  • πŸ’™ Made for Flutter. Easy to use - zero configuration
  • πŸš€ Highly scalable from hundreds to hundreds of thousands of records
  • πŸ”Ž Full-text search. Make searching fast and fun
  • πŸ“± Multiplatform. iOS, Android, Desktop and the web (soonβ„’)
  • πŸ§ͺ 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

1. Add to pubspec.yaml

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

dev_dependencies:
  isar_generator: 0.4.0
  build_runner: any

2. Define a Collection

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

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

  Links<Comment> comments; // Link to other collection
}

3. Open an instance

final isar = await openIsar();

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.

CRUD operations

All basic crud operations are available via the IsarCollection.

final newPost = Post()
  ..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();

Links

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.watchLazy;

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

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.

isar's People

Contributors

simc avatar actions-user avatar devnico avatar abhishek01039 avatar amanv8060 avatar peterwvj avatar renovate-bot avatar volser avatar

Watchers

James Cloos avatar

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.