NxCreateDocs

Database Methods

Use MongoDB-backed helpers for user properties, collection queries, and application data.

User props

Simple per-user key/value storage:

await db.setProp(userId, 'credits', 100);
const credits = await db.getProp(userId, 'credits');
await db.incrementProp(userId, 'credits', -10);

Collections

const user = await db.findOne('users', { userId });
const userViaOperation = await db.operation.findOne('users', { userId });

await db.insertOne('orders', { userId, amount: 50 });
const orders = await db.findAll('orders', { status: 'pending' });

Method reference

MethodSignatureReturns
setPropsetProp(uid, key, value)void
getPropgetProp(uid, key)any
findOnefindOne(col, query)Document | null
findAllfindAll(col, query)Document[]
updateOneupdateOne(col, filter, update)UpdateResult

Best practices

NxCreator exposes two ways to interact with your data: convenience helpers on the top-level db object for common patterns, and lower-level operations under db.operation for more control. Use whichever fits the task, but keep your collection names and data shapes consistent throughout your project.

For simple per-user state, prefer helpers such as setProp, getProp, and incrementProp. For structured app data like orders or products, work with explicit collections using findOne, findAll, and insertOne.

NxCreator handles the database connection layer for you. You write queries and updates, not connection management.
Last updated March 22, 2026
Was this page helpful?