database_universe 0.0.3 copy "database_universe: ^0.0.3" to clipboard
database_universe: ^0.0.3 copied to clipboard

discontinued

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

DatabaseUniverse Database

QuickstartDocumentationSample AppsSupport & IdeasPub.dev

DatabaseUniverse [ee-zahr]:

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

⚠️ DATABASE UNIVERSE V4 IS NOT READY FOR PRODUCTION USE ⚠️
If you want to use DatabaseUniverse 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!

DatabaseUniverse 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.flutter-io.cn 🙌💙

Quickstart #

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

1. Add to pubspec.yaml #

dependencies:
  database_universe: 4.0.0
  database_universe_flutter_libs: 4.0.0 # contains DatabaseUniverse 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 database_universe = await DatabaseUniverse.open(
  [EmailSchema],
  directory: dir.path,
);

4. Query the database #

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

DatabaseUniverse Database Inspector #

The DatabaseUniverse Inspector allows you to inspect the DatabaseUniverse 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 DatabaseUniverse app in debug mode and open the Inspector link in the logs.

CRUD operations #

All basic crud operations are available via the DatabaseUniverseCollection.

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

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

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

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

Database Queries #

DatabaseUniverse 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 = database_universe.emails
  .where()
  .titleStartsWith('Important') // use index
  .limit(10)
  .findAll()

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

Database Watchers #

With DatabaseUniverse 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 = database_universe.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, DatabaseUniverse NoSQL database is quite fast 😇

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

Unit tests #

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

DatabaseUniverse 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

Azkadev

Ura

blendthink

mnkeis

nobkd

License #

Copyright 2023 Azkadev

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.
5
likes
0
points
107
downloads

Publisher

unverified uploader

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

Topics

#database #database-universe #sqlite #encryption #storage

Documentation

Documentation

Funding

Consider supporting this project:

github.com
github.com

License

unknown (license)

Dependencies

analyzer, build, ffi, flutter, general_lib, js, meta, source_gen

More

Packages that depend on database_universe