🔗 type-mongo-mapper
A @decorator based MongoDB document to ES6 class mapper.
type-mongo-mapper makes it easy to map javascript classes to MongoDB documents and back using @decorators.
Install
yarn add type-mongo-mapper
Usage
If you want to take advantage of an upcoming feature in mongodb, you must use mongodb@3.1.0
and higher. Otherwise, you can just
use the "map" and "unmap" methods manually when dealing with plain documents. See this commit
Quickstart
; ; // pass "map" & "umap" options to collection; // Document to User // Documents to Users ; // each item in cursor will be a User // Save a User. ;user.firstName = 'John';user.lastName = 'Doe'; await collection.insertOneuser;