I am trying to build my first simple ORM based Node JS Application.
I created Database module like this
import * as Knex from 'knex';
import * as Bookshelf from 'bookshelf';
module Database {
class Config {
private static _knex: Knex = Knex({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'root',
password: '',
database: 'test',
charset: 'utf8'
}
});
static _bookshelf: Bookshelf = Bookshelf(Config._knex);
}
export function bookshelf() {
Config._bookshelf.plugin('registry');
Config._bookshelf.plugin(['virtuals']);
return Config._bookshelf;
}
}
And I am trying to use it in one of the DAO classes
/// <reference path="../models/usermodel.ts" />
/// <reference path="../network/database.ts" />
module DAO {
export class UserDAO {
create(user: Model.User): Model.User { //Model.User is imported nicely
var test = Database.bookshelf(); //what's wrong with this
return null;
}
}
}
which is ending up with this error dao/userdao.ts(18,24): error TS2304: Cannot find name 'Database'.
It's my first learning towards Typescript and Modules, let me know if I am doing something wrong.
Update:
As soon as I add import statements in database.ts, It's not working/can't find name. What I am doing wrong by using import * as something from some