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