Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plexinc/papr
MongoDB TypeScript-aware Models
https://github.com/plexinc/papr
json-schema mongodb schema typescript validation
Last synced: 5 days ago
JSON representation
MongoDB TypeScript-aware Models
- Host: GitHub
- URL: https://github.com/plexinc/papr
- Owner: plexinc
- License: mit
- Created: 2021-05-10T13:46:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-09T10:41:08.000Z (12 days ago)
- Last Synced: 2025-01-11T05:57:10.433Z (10 days ago)
- Topics: json-schema, mongodb, schema, typescript, validation
- Language: TypeScript
- Homepage: https://plexinc.github.io/papr/
- Size: 6.68 MB
- Stars: 456
- Watchers: 11
- Forks: 25
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Papr
---
- TypeScript-safe schemas
- JSON Schema MongoDB validation
- :tada: Lightweight library
- :rocket: Blazing fast---
[![Github Actions](https://github.com/plexinc/papr/actions/workflows/ci.yaml/badge.svg)](https://github.com/plexinc/papr/actions)
[![NPM version](https://img.shields.io/npm/v/papr.svg?style=flat)](https://www.npmjs.com/package/papr)
[![Install size](https://packagephobia.now.sh/badge?p=papr)](https://packagephobia.now.sh/result?p=papr)`papr` is a lightweight library built around the MongoDB NodeJS driver, written in TypeScript.
`papr` uses MongoDB's [JSON Schema validation](https://docs.mongodb.com/manual/core/schema-validation/#json-schema) feature to enable validation of document writes at runtime (requires MongoDB 3.6+).
`papr` has a familiar API - if you have used the raw `mongodb` methods to query and change documents before, then you already know how to use `papr`.
## Sample code
```ts
import Papr, { schema, types } from 'papr';const papr = new Papr();
const User = papr.model('users', schema({
age: types.number(),
firstName: types.string({ required: true }),
lastName: types.string({ required: true }),
}));const johnWick = await User.find({ firstName: 'John', lastName: 'Wick' });
```## Documentation
Read the documentation at: [plexinc.github.io/papr](https://plexinc.github.io/papr/)
## Contributing
Please read the [contributing](CONTRIBUTING.md) guidelines.
Before contributing, please read the [Code of conduct](CODE_OF_CONDUCT.md).
## License
MIT
## Inspiration
- [Mongoose](https://mongoosejs.com/)
- [ts-mongoose](https://github.com/lstkz/ts-mongoose)