Skip to content

monk-middlewares/monk-middleware-dereference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

monk-middleware-dereference

Monk middleware to handle dereferences

npm install --save monk-middleware-dereference

Usage

Let's imagine that the todos reference a user _id in their author field:

db.addMiddleware(require('monk-middleware-dereference')())

const todos = db.get('todos', {
	refMapping: {
		author: 'users'
	}
})

todos.find({}, {
	dereference: {
		author: true // get everything from the user
	}
})

todos.find({}, {
	dereference: {
		author: 'username' // only get the username from the user
	}
})

License

MIT

About

A monk middleware to handle dereferencing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published