Questions tagged [moor]

Moor: Persistence library for Dart with a fluent query API, a powerful SQL analyzer, auto-updating streams and much more, moor makes persistence fun. Scroll down to learn about moor's key features, or visit the getting started guide for a step-by-step guide on using moor.

Moor is an easy-to-use, reactive persistence library for Flutter apps. Define tables in Dart or SQL and enjoy a fluent query API, auto-updating streams, and more!

Key moor features

Here are some of the many ways moor helps you write awesome database code:

  • Auto-updating streams: With moor, any query - no matter how complex - can be turned into a stream that emits new data as the underlying data changes.
  • Polyglot: Moor lets you write queries in a fluent Dart API or directly in SQL - you can even embed Dart expressions in SQL.
  • Boilerplate-free: Stop writing mapping code yourself - moor can take of that. Moor generates Dart code around your data so you can focus on building great apps.
  • Flexible: Want to write queries in SQL? Moor verifies them at compile time and generates Dart APIs for them. Prefer to write them in Dart? Moor will generate efficient SQL for Dart queries too.
  • Easy to learn: Instead of having to learn yet another ORM, moor lets you write queries in SQL and generates typesafe wrappers. Queries and tables can also be written in Dart that looks similar to SQL without loosing type-safety
  • Fast and powerful: With the new ffi backend, moor can outperform key-value stores without putting any compromises on the integrity and flexibility that relational databases provide. Moor is the only major persistence library with built-in support for multiple isolates.
  • Well tested and production-ready: Each component of the moor is verified by a wide range of unit and integration tests. Moor powers many Flutter apps in production.
  • Cross-Platform: Moor works on iOS, Android, Linux, macOS, Windows, and on the web. It doesn't even require Flutter. See supported platforms.
15 questions
2
votes
0 answers

import db file from assets using drift/moor in flutter

I have sqlite db file and I want to import it to flutter desktop app project using drift database, i succeeded to make it work in sqflite library but I couldn't make it work in windows I don't know why so I decided to use dirft instead but it's just…
Haider IO
  • 21
  • 2
2
votes
1 answer

Drift/Moor/Flutter StateError (Bad state: No element) when selecting single row with getSingle()

When retrieving data from a Drift database using the .getSingle() method, if there is no row matching the search criterion, a StateError (Bad state: No element) error is thrown. Is this expected behavior? Future singleMyData(String id) { …
gjones
  • 33
  • 5
2
votes
0 answers

Unable to figure how to delete a row from Moor (drift) database after dart NNBD

Been trying to implement simple expense tracking app and got myself tangled in dependencies. Before null-safety deleting rows was easy, now I have to use """companions""" and their concept is a bit unintuitive for me. I've been trying to upgrade…
2
votes
1 answer

How to write customSelect query using Flutter moor/drift

I'm stuck with this custom query with variable using moor. No list is returned when using SELECT * FROM books WHERE title LIKE searchString;. Am I missing something? code: Stream> getFilteredBook(String searchString) { searchString =…
Tuss
  • 935
  • 1
  • 8
  • 14
1
vote
0 answers

Flutter Moor - How to get nullsafe GeneratedColumn?

The generic data type of a GeneratedColumn is always nullable, regardless of whether its definition has nullable() or not. It doesn't even make a difference whether I use TextColumn or Column (and similar). Example: db.dart: import…
Stacky
  • 875
  • 9
  • 24
1
vote
0 answers

Unique keys set not working on Drift Flutter

I have this table with a set of unique keys {id, order}. The problem is that when I create a new part in a different order, it automatically replaces the entire part. If I had the part with id 1 associated with order 5, when I create a new part,…
trikimg
  • 21
  • 1
1
vote
0 answers

How to stop class database file getting created multiple times when using moor?

I'm getting this error: flutter: WARNING (moor): It looks like you've created the database class AppDatabase multiple times. When these two databases use the same QueryExecutor, race conditions will occur and might corrupt the database. class…
sina .s
  • 69
  • 6
0
votes
0 answers

Can't backup data in drift(moor) database in flutter

I'm wondering how to backup my database, i have read the documentations of the drift database but i found nothing helpful for that case.
0
votes
1 answer

This row does not contain values for that table

I'm using Drift(moor). When trying to get a sample of data using leftOuterJoin, the following situation happens: The table that I join via leftOuterJoin returns null as a value. I.e. leftOuterJoin itself works correctly but values from joined table…
0
votes
0 answers

type convert of long to date time or date in moor database - flutter

I'm receiving long value from Api and I'am trying to create type convertor to convert long values to data time or date. How can I do it?
sina .s
  • 69
  • 6
0
votes
2 answers

Unhandled Exception: SqliteException(1): no such table: main.checkLists, SQL logic error (code 1) [ In Moor]

I have found most people solved this issue simply by cleaning and re building their flutter databses by handling migrations in Moor. However, I have done the same but to no avail. Current error: [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled…
erbaz kamran
  • 73
  • 1
  • 8
0
votes
1 answer

Flutter: in Moor how to change schemes and write the right onUpgrade method if there were 2 or more schemes before?

I have a database, here is how I create it: @UseMoor(tables: [ Users Images, ], daos: [ UserDao, ImageDao ]) class AppDatabase extends _$AppDatabase { AppDatabase() : super(FlutterQueryExecutor.inDatabaseFolder(path: 'my-db.sql',…
stacktrace2234
  • 1,172
  • 1
  • 12
  • 22
0
votes
2 answers

Flutter Moor Database: Joining queries proper structure

I have just started to use Moor Database for Flutter. I am going to join my two tables to get some columns from both tables. I have checked the example that is given in docs as follow: // we define a data class to contain both a todo entry and the…
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
-1
votes
1 answer

Sqflite support for aliases

Does SQFLite supports aliases like SQLite database? e.g column_name AS alias_name want to use nested select query and give nested select query value to specific field
-3
votes
1 answer

Flutter Drift - parameters prohibited in CHECK constraints

I'm trying to use the drift library (renamed from moor) ,but it's unable to create tables because of this error: SqliteException(1): parameters prohibited in CHECK constraints, SQL logic error (code 1) CREATE TABLE IF NOT EXISTS enterprise (name…
Neeraj
  • 2,376
  • 2
  • 24
  • 41