Merge pull request #86 from axellebot/patch-1
[FIX] Fixed wrong relationship example
This commit is contained in:
commit
6bad589fde
1 changed files with 9 additions and 7 deletions
16
README.md
16
README.md
|
@ -110,16 +110,18 @@ class CarController extends Controller {
|
||||||
@Expose('/recalled_since_2008')
|
@Expose('/recalled_since_2008')
|
||||||
carsRecalledSince2008(QueryExecutor executor) {
|
carsRecalledSince2008(QueryExecutor executor) {
|
||||||
// Instantiate a Car query, which is auto-generated. This class helps us build fluent queries easily.
|
// Instantiate a Car query, which is auto-generated. This class helps us build fluent queries easily.
|
||||||
var cars = new CarQuery();
|
var query = new CarQuery();
|
||||||
cars.where
|
query.where
|
||||||
..familyFriendly.equals(false)
|
..familyFriendly.equals(false)
|
||||||
..recalledAt.year.greaterThanOrEqualTo(2008);
|
..recalledAt.year.greaterThanOrEqualTo(2008);
|
||||||
|
|
||||||
// Shorter syntax we could use instead...
|
// Shorter syntax we could use instead...
|
||||||
cars.where.recalledAt.year <= 2008;
|
query.where.recalledAt.year <= 2008;
|
||||||
|
|
||||||
// `get()` returns a Future<List<Car>>.
|
// `get()` returns a Future<List<Car>>.
|
||||||
return await cars.get(executor);
|
var cars = await query.get(executor);
|
||||||
|
|
||||||
|
return cars;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Expose('/create', method: 'POST')
|
@Expose('/create', method: 'POST')
|
||||||
|
@ -154,15 +156,15 @@ with custom parameters (ex. `@HasOne(foreignKey: 'foreign_id')`).
|
||||||
@orm
|
@orm
|
||||||
abstract class _Author extends Model {
|
abstract class _Author extends Model {
|
||||||
@hasMany // Use the defaults, and auto-compute `foreignKey`
|
@hasMany // Use the defaults, and auto-compute `foreignKey`
|
||||||
List<Book> books;
|
List<_Book> books;
|
||||||
|
|
||||||
// Also supports parameters...
|
// Also supports parameters...
|
||||||
@HasMany(localKey: 'id', foreignKey: 'author_id', cascadeOnDelete: true)
|
@HasMany(localKey: 'id', foreignKey: 'author_id', cascadeOnDelete: true)
|
||||||
List<Book> books;
|
List<_Book> books;
|
||||||
|
|
||||||
@SerializableField(alias: 'writing_utensil')
|
@SerializableField(alias: 'writing_utensil')
|
||||||
@hasOne
|
@hasOne
|
||||||
Pen pen;
|
_Pen pen;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue