diff --git a/angel_orm_generator/lib/src/orm_generator.dart b/angel_orm_generator/lib/src/orm_generator.dart index b4649fb1..5c20ecb8 100644 --- a/angel_orm_generator/lib/src/orm_generator.dart +++ b/angel_orm_generator/lib/src/orm_generator.dart @@ -86,13 +86,33 @@ class OrmGenerator extends GeneratorForAnnotation { lib.body.add(new Code("part '$dbFile';")); // Create `FooOrm` abstract class - var rc = new ReCase(ctx.buildContext.modelClassName); + var rc = ctx.buildContext.modelClassNameRecase; lib.body.add(new Class((clazz) { clazz ..name = '${rc.pascalCase}Orm' ..abstract = true; + // Add factory constructors. + switch (ctx.ormAnnotation.type) { + case OrmType.postgreSql: + clazz.constructors.add(new Constructor((b) { + b + ..name = 'postgreSql' + ..factory = true + ..redirect = refer('_PostgreSql${rc.pascalCase}OrmImpl') + ..requiredParameters.add(new Parameter((b) { + b + ..name = 'connection' + ..type = refer('PostgreSQLConnection'); + })); + })); + dbExtension = 'postgresql'; + break; + default: + break; + } + // Next, add method stubs. // * getAll // * getById diff --git a/angel_orm_generator/lib/src/postgresql_orm_generator.dart b/angel_orm_generator/lib/src/postgresql_orm_generator.dart index 5c075aaa..7bdedf4f 100644 --- a/angel_orm_generator/lib/src/postgresql_orm_generator.dart +++ b/angel_orm_generator/lib/src/postgresql_orm_generator.dart @@ -49,7 +49,7 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation { return new Class((clazz) { var rc = ctx.buildContext.modelClassNameRecase; clazz - ..name = '_Postgresql${rc.pascalCase}OrmImpl' + ..name = '_PostgreSql${rc.pascalCase}OrmImpl' ..implements.add(refer('${rc.pascalCase}Orm')) // final PostgreSQLConnection connection;