Merge pull request #86 from axellebot/patch-1

[FIX] Fixed wrong relationship example
This commit is contained in:
Tobe Osakwe 2019-07-17 18:41:54 -04:00 committed by GitHub
commit 6bad589fde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,16 +110,18 @@ class CarController extends Controller {
@Expose('/recalled_since_2008')
carsRecalledSince2008(QueryExecutor executor) {
// Instantiate a Car query, which is auto-generated. This class helps us build fluent queries easily.
var cars = new CarQuery();
cars.where
var query = new CarQuery();
query.where
..familyFriendly.equals(false)
..recalledAt.year.greaterThanOrEqualTo(2008);
// Shorter syntax we could use instead...
cars.where.recalledAt.year <= 2008;
query.where.recalledAt.year <= 2008;
// `get()` returns a Future<List<Car>>.
return await cars.get(executor);
var cars = await query.get(executor);
return cars;
}
@Expose('/create', method: 'POST')
@ -154,15 +156,15 @@ with custom parameters (ex. `@HasOne(foreignKey: 'foreign_id')`).
@orm
abstract class _Author extends Model {
@hasMany // Use the defaults, and auto-compute `foreignKey`
List<Book> books;
List<_Book> books;
// Also supports parameters...
@HasMany(localKey: 'id', foreignKey: 'author_id', cascadeOnDelete: true)
List<Book> books;
List<_Book> books;
@SerializableField(alias: 'writing_utensil')
@hasOne
Pen pen;
_Pen pen;
}
```