Gen base postgres class

This commit is contained in:
Tobe O 2018-08-28 11:12:29 -04:00
parent c2fe5449a7
commit 41f1165a1f
30 changed files with 190 additions and 9 deletions

View file

@ -37,9 +37,36 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation<Orm> {
Library buildOrmLibrary(AssetId inputId, OrmBuildContext ctx) {
return new Library((lib) {
// Add part of
var libFile =
p.setExtension(p.basename(inputId.uri.path), '.orm.g.dart');
var libFile = p.setExtension(p.basename(inputId.uri.path), '.orm.g.dart');
lib.body.add(new Code("part of '$libFile';"));
// Add _PostgresqlFooOrmImpl
lib.body.add(buildOrmClass(ctx));
});
}
Class buildOrmClass(OrmBuildContext ctx) {
return new Class((clazz) {
var rc = ctx.buildContext.modelClassNameRecase;
clazz
..name = '_Postgresql${rc.pascalCase}OrmImpl'
..implements.add(refer('${rc.pascalCase}Orm'))
// final PostgreSQLConnection connection;
..fields.add(new Field((b) {
b
..modifier = FieldModifier.final$
..name = 'connection'
..type = refer('PostgreSQLConnection');
}))
// _PostgresqlFooOrmImpl(this.connection);
..constructors.add(new Constructor((b) {
b
..requiredParameters.add(new Parameter((b) => b
..name = 'connection'
..toThis = true));
}));
});
}
}

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'author.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'author.dart';
part 'author.postgresql.orm.dart';
part 'author.postgresql.orm.g.dart';
abstract class AuthorOrm {
Future<List<Author>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'author.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "author" with type "Author".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "author" with type "Author".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'car.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'car.dart';
part 'car.postgresql.orm.dart';
part 'car.postgresql.orm.g.dart';
abstract class CarOrm {
Future<List<Car>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'car.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'customer.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'customer.dart';
part 'customer.postgresql.orm.dart';
part 'customer.postgresql.orm.g.dart';
abstract class CustomerOrm {
Future<List<Customer>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'customer.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'foot.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'foot.dart';
part 'foot.postgresql.orm.dart';
part 'foot.postgresql.orm.g.dart';
abstract class FootOrm {
Future<List<Foot>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'foot.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'fruit.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'fruit.dart';
part 'fruit.postgresql.orm.dart';
part 'fruit.postgresql.orm.g.dart';
abstract class FruitOrm {
Future<List<Fruit>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'fruit.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "foot" with type "Foot".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "foot" with type "Foot".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'order.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'order.dart';
part 'order.postgresql.orm.dart';
part 'order.postgresql.orm.g.dart';
abstract class OrderOrm {
Future<List<Order>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'order.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
part of 'role.orm.g.dart';

View file

@ -6,7 +6,7 @@
import 'dart:async';
import 'role.dart';
part 'role.postgresql.orm.dart';
part 'role.postgresql.orm.g.dart';
abstract class RoleOrm {
Future<List<Role>> getAll();

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
part of 'role.orm.g.dart';

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "fruits" with type "List".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "fruits" with type "List".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// MongoDBOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "roles" with type "List".

View file

@ -0,0 +1,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// PostgreSqlOrmGenerator
// **************************************************************************
// Error: Cannot infer SQL column type for field "roles" with type "List".