ThreadsDB
const Astronauts = await db.newCollectionFromObject('Astronauts', {
ID: '',
name: '',
missions: 0,
})
db.on('Astronauts.**', update => {
console.log(update) // subscribe to updates
})
await Astronauts.insert(
{ ID: '', missions: 2, name: 'Buzz Aldrin' },
{ ID: '', missions: 5, name: 'Christina Koch' },
{ ID: '', missions: 2, name: 'Sally Ride' },
{ ID: '', missions: 7, name: 'Jerry Ross' },
)
const all = Collection.find(
{ $or: [{ missions: { $gt: 2 } }, { name: 'Sally Ride' }] },
{ sort: { missions: -1 } }
)
for await (const { key, value } of all) {
console.log(value)
}
• Every Thread (networking)
has a Database
• Every Database has 1-to-
many Collections (schemas)
• Collections have many
instances (documents
matching schemas)
• Instances can be added,
deleted, or updated.
The database — simple