如何使用类型脚本类语法使用NeDB获得数据存储?
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() {
...
}
}
}应该在哪里创建和实例化我的数据存储?
发布于 2016-12-14 04:10:17
我自己在这上面旋转了一段时间,我可以用以下方法生成数据库:
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);
}备注:
https://stackoverflow.com/questions/38875580
复制相似问题