[英]How do I use persist with node.js?
我正在嘗試熟悉該節點的持久性軟件包。 有人可以告訴我是否使用persist.connect在這里建立連接,還是這些屬性?
var persist = require("persist");
var type = persist.type;
// define some model objects
Phone = persist.define("Phone", {
"number": type.STRING
});
Person = persist.define("Person", {
"name": type.STRING
}).hasMany(this.Phone);
persist.connect({
driver: 'sqlite3',
filename: 'test.db',
trace: true
}, function(err, connection) {
Person.using(connection).all(function(err, people) {
// people contains all the people
});
});
如果我將this.Phone
更改為Phone
則上面的代碼在我的系統上運行不會出錯。
persist.connect
“連接”到包含數據庫的test.db
文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.