В приведенном ниже коде в строке 49 в async function renderMessages()
я не могу отобразить поле name . Я просто хочу показать данные поля имени.
Я старался изо всех сил даже в официальной документации (https://rxdb.info/rx-document.html#tojson).
Основным обновлением rxdb было запущен на этой неделе для 9.0.0 после нескольких бета-релизов.
async function renderMessages() {
const db = await createDatabase();
const messagesCollection = db['category1'];
const messageDocument = await messagesCollection.find().exec();
// writing the value of
console.log('-------------');
messagesCollection.find().exec() // <- find all documents
.then(documents => console.log(documents));
console.log(messageDocument.length);
console.log('data fetched')
return (
'output name'
);
}
Посмотрите на функцию createDatabase ()
async function createDatabase() {
const db = await createRxDatabase(
{ name: 'categorydb', adapter: 'idb', password: '12345678',ignoreDuplicate: true }
);
const messagesCollection = await db.collection({
name: "category1",
schema: categorySchema
});
const replicationState =
messagesCollection.sync({ remote: syncURL + dbName + '/' });
subs.push(
replicationState.change$.subscribe(change => {
console.log('Replication change');
console.dir(change)
})
);
subs.push(
replicationState.docs$.subscribe(docData => {
console.log('replication docs');
console.dir(docData)
})
);
subs.push(
replicationState.active$.subscribe(active => console.log(`Replication active: ${active}`))
);
subs.push(
replicationState.complete$.subscribe(completed => console.log(`Replication completed: ${completed}`))
);
subs.push(
replicationState.error$.subscribe(error => {
console.log('Replication Error');
console.dir(error)
})
);
return db;
}
CouchDB
имеет Базы данных и Документы , тогда как rxdb
вводит базы данных , коллекции и документы , так что это оказывается трудным для понимания