
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Monjoi - A lightweight alternative to Mongoose.
npm i monjoi
# or with Yarn
yarn add monjoi
* Monjoi has peer dependencies on Joi and node mongodb driver.
// person.model.ts
import Joi from 'joi'
import { collection } from 'monjoi'
export type Person = {
name: string
age?: number
}
const PersonSchema = Joi.object<Person>({
name: Joi.string().required(),
age: Joi.number()
})
// Person - Data Access Object
export const PersonDAO = collection('person', PersonSchema)
// TODO: Example needed
// person.service.ts
import { Person, PersonDAO } from './person.model.ts'
class PersonService {
constructor(
// Dependency Injected `personDAO`
private personDAO: PersonDAO
) {}
public async createPerson(person: Person): Promise<Person> {
// Automatically validates `person` against Joi schema
// and returns the newly inserted mongo document with _id
return this.personDAO.insertOne(person)
}
}
There are 2 types of hooks available:
Hooks can return regular values or even Promises.
Useful for triggering other operations before accessing the db. If a hook returns a rejected promise, then the main db operation will not execute, neither will the Post hooks.
Useful for formatting db responses or triggering other operations. Post hooks should generally return objects because they will be passed to the next hook.
Any hook that returns a rejected promise will cancel the hook chain.
Hooks are declared when defining your DAO. You can hook into any standard mongodb collection operation.
export const PersonDAO = collection('person', PersonSchema, {
insertOne: {
pre: [
() => console.log('I will run before any insertOne operation for person collection'),
() => console.log('me too!')
],
post: [
(insertedDoc) => {
console.log(`Document ${insertedDoc._id} created!`)
return insertedDoc // <-- Don't forget to return objects from post hooks
},
(insertedDoc) => {
// formatting example, removing mongo __v field
return omit(insertedDoc, ['__v'])
}
]
}
})
FAQs
MongoDB + Joi
The npm package monjoi receives a total of 3 weekly downloads. As such, monjoi popularity was classified as not popular.
We found that monjoi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.