Add facory constructor for postgres
This commit is contained in:
parent
9dffee9bc7
commit
576fdc6d8a
2 changed files with 22 additions and 2 deletions
|
@ -86,13 +86,33 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
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
|
||||
|
|
|
@ -49,7 +49,7 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue