Database
Esta página aún no está disponible en tu idioma.
This guide will help you to understand the database.
Direct MongoDB Integration
Section titled “Direct MongoDB Integration”Zumito Framework has moved from custom database models to a direct MongoDB integration. This means that you can now use the official MongoDB driver to interact with the database.
Accessing the Database
Section titled “Accessing the Database”To access the database, you need to get the Db
object from the ServiceContainer
.
import { ServiceContainer } from 'zumito-framework';import { Db } from 'mongodb';
const db = ServiceContainer.get(Db);
Once you have the Db
object, you can use it to interact with the database.
const users = await db.collection('users').find().toArray();