Add OrmType
This commit is contained in:
parent
19c9095700
commit
849c4281bc
12 changed files with 24 additions and 14 deletions
|
@ -1,3 +1,6 @@
|
|||
# 2.0.0-dev.2
|
||||
* Renamed `ORM` to `Orm`.
|
||||
|
||||
# 2.0.0-dev.1
|
||||
* Restored all old PostgreSQL-specific annotations. Rather than a smart runtime,
|
||||
having a codegen capable of building ORM's for multiple databases can potentially
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
const ORM orm = const ORM();
|
||||
const Orm orm = const Orm();
|
||||
|
||||
class ORM {
|
||||
class Orm {
|
||||
final String tableName;
|
||||
|
||||
const ORM([this.tableName]);
|
||||
const Orm({this.tableName});
|
||||
}
|
||||
|
||||
enum OrmType {
|
||||
mongoDB,
|
||||
rethinkDB,
|
||||
mySql,
|
||||
postgreSql,
|
||||
}
|
||||
|
||||
class CanJoin {
|
||||
|
|
|
@ -114,7 +114,7 @@ Column reviveColumn(ConstantReader cr) {
|
|||
|
||||
class OrmBuildContext {
|
||||
final BuildContext buildContext;
|
||||
final ORM ormAnnotation;
|
||||
final Orm ormAnnotation;
|
||||
final String tableName;
|
||||
|
||||
final Map<String, Column> columns = {};
|
||||
|
|
|
@ -22,7 +22,7 @@ TypeReference futureOf(String type) {
|
|||
}
|
||||
|
||||
/// Builder that generates `.orm.g.dart`, with an abstract `FooOrm` class.
|
||||
class OrmGenerator extends GeneratorForAnnotation<ORM> {
|
||||
class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
||||
final bool autoSnakeCaseNames;
|
||||
final bool autoIdAndDateFields;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import 'package:source_gen/source_gen.dart';
|
|||
|
||||
const TypeChecker columnTypeChecker = const TypeChecker.fromRuntime(Column);
|
||||
|
||||
ORM reviveORMAnnotation(ConstantReader reader) {
|
||||
return ORM(reader.peek('tableName')?.stringValue);
|
||||
Orm reviveORMAnnotation(ConstantReader reader) {
|
||||
return Orm(reader.peek('tableName')?.stringValue);
|
||||
}
|
||||
|
||||
class ColumnReader {
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'author.dart';
|
|||
abstract class AuthorOrm {
|
||||
Future<List<Author>> getAll();
|
||||
Future<Author> getById(id);
|
||||
Future<Author> updateAuthor(Author model);
|
||||
Future<Author> update(Author model);
|
||||
AuthorQuery query();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'car.dart';
|
|||
abstract class CarOrm {
|
||||
Future<List<Car>> getAll();
|
||||
Future<Car> getById(id);
|
||||
Future<Car> updateCar(Car model);
|
||||
Future<Car> update(Car model);
|
||||
CarQuery query();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'customer.dart';
|
|||
abstract class CustomerOrm {
|
||||
Future<List<Customer>> getAll();
|
||||
Future<Customer> getById(id);
|
||||
Future<Customer> updateCustomer(Customer model);
|
||||
Future<Customer> update(Customer model);
|
||||
CustomerQuery query();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'foot.dart';
|
|||
abstract class FootOrm {
|
||||
Future<List<Foot>> getAll();
|
||||
Future<Foot> getById(id);
|
||||
Future<Foot> updateFoot(Foot model);
|
||||
Future<Foot> update(Foot model);
|
||||
FootQuery query();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'fruit.dart';
|
|||
abstract class FruitOrm {
|
||||
Future<List<Fruit>> getAll();
|
||||
Future<Fruit> getById(id);
|
||||
Future<Fruit> updateFruit(Fruit model);
|
||||
Future<Fruit> update(Fruit model);
|
||||
FruitQuery query();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'order.dart';
|
|||
abstract class OrderOrm {
|
||||
Future<List<Order>> getAll();
|
||||
Future<Order> getById(id);
|
||||
Future<Order> updateOrder(Order model);
|
||||
Future<Order> update(Order model);
|
||||
OrderQuery query();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'role.dart';
|
|||
abstract class RoleOrm {
|
||||
Future<List<Role>> getAll();
|
||||
Future<Role> getById(id);
|
||||
Future<Role> updateRole(Role model);
|
||||
Future<Role> update(Role model);
|
||||
RoleQuery query();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue