Change updateFoo to update
This commit is contained in:
parent
bf24371932
commit
19c9095700
8 changed files with 100 additions and 8 deletions
|
@ -15,6 +15,12 @@ Builder ormBuilder(_) {
|
|||
generatedExtension: '.orm.g.dart');
|
||||
}
|
||||
|
||||
TypeReference futureOf(String type) {
|
||||
return new TypeReference((b) => b
|
||||
..symbol = 'Future'
|
||||
..types.add(refer(type)));
|
||||
}
|
||||
|
||||
/// Builder that generates `.orm.g.dart`, with an abstract `FooOrm` class.
|
||||
class OrmGenerator extends GeneratorForAnnotation<ORM> {
|
||||
final bool autoSnakeCaseNames;
|
||||
|
@ -54,7 +60,44 @@ class OrmGenerator extends GeneratorForAnnotation<ORM> {
|
|||
// Next, add method stubs.
|
||||
// * getAll
|
||||
// * getById
|
||||
// *
|
||||
// * update
|
||||
// * query()
|
||||
|
||||
// getAll
|
||||
clazz.methods.add(new Method((m) {
|
||||
m
|
||||
..name = 'getAll'
|
||||
..returns = new TypeReference((b) => b
|
||||
..symbol = 'Future'
|
||||
..types.add(new TypeReference((b) => b
|
||||
..symbol = 'List'
|
||||
..types.add(ctx.buildContext.modelClassType))));
|
||||
}));
|
||||
|
||||
// getById
|
||||
clazz.methods.add(new Method((m) {
|
||||
m
|
||||
..name = 'getById'
|
||||
..returns = futureOf(ctx.buildContext.modelClassName)
|
||||
..requiredParameters.add(new Parameter((b) => b..name = 'id'));
|
||||
}));
|
||||
|
||||
// update
|
||||
clazz.methods.add(new Method((m) {
|
||||
m
|
||||
..name = 'update'
|
||||
..returns = futureOf(ctx.buildContext.modelClassName)
|
||||
..requiredParameters.add(new Parameter((b) => b
|
||||
..name = 'model'
|
||||
..type = ctx.buildContext.modelClassType));
|
||||
}));
|
||||
|
||||
// query()
|
||||
clazz.methods.add(new Method((m) {
|
||||
m
|
||||
..name = 'query'
|
||||
..returns = refer('${rc.pascalCase}Query');
|
||||
}));
|
||||
}));
|
||||
|
||||
// Create `FooQuery` class
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'author.dart';
|
||||
|
||||
abstract class AuthorOrm {}
|
||||
abstract class AuthorOrm {
|
||||
Future<List<Author>> getAll();
|
||||
Future<Author> getById(id);
|
||||
Future<Author> updateAuthor(Author model);
|
||||
AuthorQuery query();
|
||||
}
|
||||
|
||||
class AuthorQuery {}
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'car.dart';
|
||||
|
||||
abstract class CarOrm {}
|
||||
abstract class CarOrm {
|
||||
Future<List<Car>> getAll();
|
||||
Future<Car> getById(id);
|
||||
Future<Car> updateCar(Car model);
|
||||
CarQuery query();
|
||||
}
|
||||
|
||||
class CarQuery {}
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'customer.dart';
|
||||
|
||||
abstract class CustomerOrm {}
|
||||
abstract class CustomerOrm {
|
||||
Future<List<Customer>> getAll();
|
||||
Future<Customer> getById(id);
|
||||
Future<Customer> updateCustomer(Customer model);
|
||||
CustomerQuery query();
|
||||
}
|
||||
|
||||
class CustomerQuery {}
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'foot.dart';
|
||||
|
||||
abstract class FootOrm {}
|
||||
abstract class FootOrm {
|
||||
Future<List<Foot>> getAll();
|
||||
Future<Foot> getById(id);
|
||||
Future<Foot> updateFoot(Foot model);
|
||||
FootQuery query();
|
||||
}
|
||||
|
||||
class FootQuery {}
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'fruit.dart';
|
||||
|
||||
abstract class FruitOrm {}
|
||||
abstract class FruitOrm {
|
||||
Future<List<Fruit>> getAll();
|
||||
Future<Fruit> getById(id);
|
||||
Future<Fruit> updateFruit(Fruit model);
|
||||
FruitQuery query();
|
||||
}
|
||||
|
||||
class FruitQuery {}
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'order.dart';
|
||||
|
||||
abstract class OrderOrm {}
|
||||
abstract class OrderOrm {
|
||||
Future<List<Order>> getAll();
|
||||
Future<Order> getById(id);
|
||||
Future<Order> updateOrder(Order model);
|
||||
OrderQuery query();
|
||||
}
|
||||
|
||||
class OrderQuery {}
|
||||
|
|
|
@ -7,4 +7,11 @@
|
|||
import 'dart:async';
|
||||
import 'role.dart';
|
||||
|
||||
abstract class RoleOrm {}
|
||||
abstract class RoleOrm {
|
||||
Future<List<Role>> getAll();
|
||||
Future<Role> getById(id);
|
||||
Future<Role> updateRole(Role model);
|
||||
RoleQuery query();
|
||||
}
|
||||
|
||||
class RoleQuery {}
|
||||
|
|
Loading…
Reference in a new issue