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';"));
|
lib.body.add(new Code("part '$dbFile';"));
|
||||||
|
|
||||||
// Create `FooOrm` abstract class
|
// Create `FooOrm` abstract class
|
||||||
var rc = new ReCase(ctx.buildContext.modelClassName);
|
var rc = ctx.buildContext.modelClassNameRecase;
|
||||||
|
|
||||||
lib.body.add(new Class((clazz) {
|
lib.body.add(new Class((clazz) {
|
||||||
clazz
|
clazz
|
||||||
..name = '${rc.pascalCase}Orm'
|
..name = '${rc.pascalCase}Orm'
|
||||||
..abstract = true;
|
..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.
|
// Next, add method stubs.
|
||||||
// * getAll
|
// * getAll
|
||||||
// * getById
|
// * getById
|
||||||
|
|
|
@ -49,7 +49,7 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation<Orm> {
|
||||||
return new Class((clazz) {
|
return new Class((clazz) {
|
||||||
var rc = ctx.buildContext.modelClassNameRecase;
|
var rc = ctx.buildContext.modelClassNameRecase;
|
||||||
clazz
|
clazz
|
||||||
..name = '_Postgresql${rc.pascalCase}OrmImpl'
|
..name = '_PostgreSql${rc.pascalCase}OrmImpl'
|
||||||
..implements.add(refer('${rc.pascalCase}Orm'))
|
..implements.add(refer('${rc.pascalCase}Orm'))
|
||||||
|
|
||||||
// final PostgreSQLConnection connection;
|
// final PostgreSQLConnection connection;
|
||||||
|
|
Loading…
Reference in a new issue