Skip to content
/ mango Public

🦕🥭 Delicious way to work with mongodb from deno

Notifications You must be signed in to change notification settings

jokio/mango

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🥭 Mango

Lightweight repository abstraction layer on top of the mongodb driver to provide missing features. It has never been so delicious working with mongo.

codecov

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:

import { connectMongo, MangoRepo } from 'https://deno.land/x/[email protected]/mod.ts'

type User = {
  name: string
  avatarUrl: string
}

const { db } = await connectMongo('mongo:https://localhost/test')
const repo = new MangoRepo<User>(
  db,
  'users',
)

const result = await repo.insert({
  name: 'playerx',
  avatarUrl: 'myJokAvatar',
})

console.log(result)

Advanced Examples:

Check out tests/mangoRepo

About

🦕🥭 Delicious way to work with mongodb from deno

Topics

Resources

Stars

Watchers

Forks