Reputation: 355
How can I get a datastore with NeDB using typescrip classes syntax?
namespace NamespaceName {
"use strict";
export class Persistence {
private attrs: Type;
public static $inject: Array<string> = [];
constructor(
) {
this.attr1 = "";
}
// Public Methods
public method1() {
...
}
// Private Methods
private method1() {
...
}
}
}
Where should I create and instantiate my datastore?
Upvotes: 1
Views: 3465
Reputation: 36
I was spinning my wheels on this myself for a while and I was able to do get the database to generate with the following:
import NeDB = require('nedb');
//test class
class duck{
body: string;
constructor(body: string)
{
this.body = body;
}
}
//method from where I init my database.
testdb() {
var db:any = new NeDB("./file.db");
var obj:duck= new duck("A normal duck body");
db.loadDatabase();
db.insert(obj);
}
Notes:
Upvotes: 1