Databasev0.1.5
@tekir/mongodb
MongoDB via Mongoose with CRUD, soft deletes, pagination, and aggregation.
Installation
$
bun add @tekir/mongodbFeatures
- BaseModel with Mongoose schema auto-registration
- CRUD operations: create, find, update, delete
- Lifecycle hooks via decorators or static hooks property
- Soft deletes and pagination built in
- MongoProvider for service container integration
Quick Example
TypeScript
import { BaseModel, mongo } from '@tekir/mongodb'
class Post extends BaseModel {
static schema = { title: String, body: String }
}
await mongo.connect('mongodb://localhost/mydb')
const post = await Post.create({ title: 'Hello', body: '...' })Changelog
v0.1.5LatestSeptember 16, 2026
- Published output now uses the shared Node-targeted ESM bundle pipeline with external dependencies and generated TypeScript declarations, while Bun consumers keep the native source export.
v0.1.4July 23, 2026
- Mongoose uses the package's resolved module instance consistently, including combined and parallel test runs.
v0.1.2July 16, 2026
- Write/delete ID paths reject operator objects and invalid identifiers before reaching Mongoose, and fillable assignment ignores inherited properties.
v0.1.1June 13, 2026
- Query filters are now sanitized against NoSQL injection.
find,findOne,count,exists,deleteMany,updateMany,distinct,paginate, and the soft-delete scopes strip operator keys (those starting with$or containing.) at every depth, while preservingDate/ObjectIdand hand-built queries. - Update operations are now guarded: plain field maps are wrapped in
$set, and explicit operator documents keep only a safe allowlist, so$rename/$unset/$where-style operators cannot be smuggled through. findByIdreturnsnullfor non-string, object, or invalid ObjectId ids instead of throwing a CastError, sofindOrFailgives a consistent not-found result for crafted ids.- Connections now apply pool-size and timeout defaults and attach an error handler (errors surface as a
tekir:errorevent instead of an unhandled rejection). Query debug logging is off unlessdebug: trueis set, so filter values are not logged by default. - Found and fixed with Fable.
v0.1.0April 1, 2026
- Initial release