Skip to content

Latest commit

 

History

History
executable file
·
38 lines (28 loc) · 578 Bytes

README.md

File metadata and controls

executable file
·
38 lines (28 loc) · 578 Bytes

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