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) { Library buildOrmLibrary(AssetId inputId, OrmBuildContext ctx) {
return new Library((lib) { return new Library((lib) {
// Add part of // Add part of
var libFile = var libFile = p.setExtension(p.basename(inputId.uri.path), '.orm.g.dart');
p.setExtension(p.basename(inputId.uri.path), '.orm.g.dart');
lib.body.add(new Code("part of '$libFile';")); 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 'dart:async';
import 'author.dart'; import 'author.dart';
part 'author.postgresql.orm.dart'; part 'author.postgresql.orm.g.dart';
abstract class AuthorOrm { abstract class AuthorOrm {
Future<List<Author>> getAll(); 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 'dart:async';
import 'car.dart'; import 'car.dart';
part 'car.postgresql.orm.dart'; part 'car.postgresql.orm.g.dart';
abstract class CarOrm { abstract class CarOrm {
Future<List<Car>> getAll(); 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 'dart:async';
import 'customer.dart'; import 'customer.dart';
part 'customer.postgresql.orm.dart'; part 'customer.postgresql.orm.g.dart';
abstract class CustomerOrm { abstract class CustomerOrm {
Future<List<Customer>> getAll(); 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 'dart:async';
import 'foot.dart'; import 'foot.dart';
part 'foot.postgresql.orm.dart'; part 'foot.postgresql.orm.g.dart';
abstract class FootOrm { abstract class FootOrm {
Future<List<Foot>> getAll(); 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 'dart:async';
import 'fruit.dart'; import 'fruit.dart';
part 'fruit.postgresql.orm.dart'; part 'fruit.postgresql.orm.g.dart';
abstract class FruitOrm { abstract class FruitOrm {
Future<List<Fruit>> getAll(); 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 'dart:async';
import 'order.dart'; import 'order.dart';
part 'order.postgresql.orm.dart'; part 'order.postgresql.orm.g.dart';
abstract class OrderOrm { abstract class OrderOrm {
Future<List<Order>> getAll(); 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 'dart:async';
import 'role.dart'; import 'role.dart';
part 'role.postgresql.orm.dart'; part 'role.postgresql.orm.g.dart';
abstract class RoleOrm { abstract class RoleOrm {
Future<List<Role>> getAll(); 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".