私はnode.jsからクエリする必要があるMySQLデータベースを持っています.fetchAllの後に行をループする方法Bookshelf js + knex js?
私は本棚とknexを使っています。
テーブルの内容を取得したい - 私のmodel.jsファイルにテーブルを定義しました。それは複数の行でなければなりませんので、私はどのようにresDataをループに知っていただきたいと思います
//select * from completedSentences;
Model.CompletedSentences.fetchAll().then(function (resData) {
console.log(resData)
})
:私はこのようなクエリをしようとしています。
コンソールの出力は次のようになります。ループする行のリストは表示されません。何が欠けていますか?
CollectionBase {
model:
{ [Function]
NotFoundError: [Function: ErrorCtor],
NoRowsUpdatedError: [Function: ErrorCtor],
NoRowsDeletedError: [Function: ErrorCtor] },
length: 1,
models:
[ ModelBase {
attributes: [Object],
_previousAttributes: [Object],
changed: {},
relations: {},
cid: 'c4',
id: 1 } ],
_byId:
{ '1':
ModelBase {
attributes: [Object],
_previousAttributes: [Object],
changed: {},
relations: {},
cid: 'c4',
id: 1 },
c4:
ModelBase {
attributes: [Object],
_previousAttributes: [Object],
changed: {},
relations: {},
cid: 'c4',
id: 1 } },
_knex: null,
_events: {},
_eventsCount: 0 }
うわー、私はすべてのドキュメント上で見て、できなかったですこの単純なことをする方法を見つける – Jonah
私はそれを探して正確に私の考え... –
私のために私はresult.lenghtが等しいことがわかったresult.models.length ((( –