1
jsフレームワーク。私はポスト要求からDBにデータを保存するためにTotal.jsデータベースにデータを保存
モデル(article.js)しようとしている:
NEWSCHEMA('Article').make(function(schema) {
schema.define('title', 'String', true); // title of article
schema.define('about', 'String', true); // about
schema.define('text', 'String', true); // text
schema.define('date', 'Date'); // created date
schema.setSave(function(error , model, options, callback){
var sql = DB(error);
sql.insert('articles').make(function(builder) {
builder.set('title', model.title);
builder.set('about', model.about);
builder.set('text', model.text);
builder.set('date', F.datetime);
});
sql.exec(n => callback(SUCCESS(true)));
});
});
を、私は、コントローラ(にDefault.js)があります。
exports.install = function() {
F.route('/add_article', add_article, ['authorize', '*Article', 'post']);
};
function add_article(){
var self = this;
self.body.$save(self, self.callback());
}
しかし、私は思いますエラーが発生しました:
======= default ---> TypeError: sql.insert(...).make is not a function (http://127.0.0.1:8000/add_article?ts=1489500750601)TypeError: sql.insert(...).make is not a function
ありがとうございます。あなたがエラーを渡している。このラインでDBに
var sql = DB(error);
にエラーを入力している
あなたはSQLエージェントをインストールしてinitalizedているかを使用する必要がありますか? –