Ho un database MySQL che ho bisogno di interrogare da node.jsCome eseguire il looping delle righe dopo .fetchAll Bookshelf js + knex js?
Sto usando librerie e knex per questo.
voglio ottenere il contenuto di una tabella - ho definito una tabella nel mio file model.js. Sto tentando la query come questa:
//select * from completedSentences;
Model.CompletedSentences.fetchAll().then(function (resData) {
console.log(resData)
})
Vorrei sapere come un ciclo su resData perché dovrebbe essere più righe.
L'uscita della console si presenta così: non vedo un elenco di righe posso ciclo su .. Cosa mi manca?
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 }
Wow ho guardato tutto la documentazione e non poteva trovare come fare questa cosa semplice – Jonah
esattamente i miei pensieri quando l'ho cercato ... –
Per quanto riguarda me, ho trovato che result.lenght non è uguale result.models.length ((( –