https://github.com/jokio/mango
🦕🥠Delicious way to work with mongodb from deno
https://github.com/jokio/mango
deno mongodb typescript
Last synced: about 2 months ago
JSON representation
🦕🥠Delicious way to work with mongodb from deno
- Host: GitHub
- URL: https://github.com/jokio/mango
- Owner: jokio
- Created: 2021-12-21T12:02:36.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-15T18:09:13.000Z (over 2 years ago)
- Last Synced: 2026-04-03T15:28:47.748Z (3 months ago)
- Topics: deno, mongodb, typescript
- Language: TypeScript
- Homepage:
- Size: 42 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🥠Mango
Lightweight repository abstraction layer on top of the mongodb driver to provide missing features. It has never been so delicious working with `mongo`.
##
[](https://codecov.io/gh/jokio/mango)
## Features
✅ `_id` mapping to `id`. In mongo it's not possible to use id instead of _id, this feature automatically maps id field for you (enabled by default).
✅ `_id` transformation from `ObjectId` to `string`. So you will work with strings always and `ObjectId` will be stored in mongo for you. You will not need to worry about conversions any more once it's enabled (enabled by default).
✅ Versioning system can be enabled per collection. `version: number` and its increased by `1` every time you call update. Can be used for optimistic concurency.
✅ Doc Dates can be enabled per collection and documents will have `createdAt` and `updatedAt`.
## Basic Example:
```ts
import { connectMongo, MangoRepo } from 'https://deno.land/x/jok_mango@v1.4.0/mod.ts'
type User = {
name: string
avatarUrl: string
}
const { db } = await connectMongo('mongo://localhost/test')
const repo = new MangoRepo(
db,
'users',
)
const result = await repo.insert({
name: 'playerx',
avatarUrl: 'myJokAvatar',
})
console.log(result)
```
## Advanced Examples:
Check out [tests/mangoRepo](https://github.com/jokio/mango/tree/main/tests/mangoRepo)