Skip to content

Database

This guide will help you to understand the database.

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.

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();