ccd-mongo
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Build Status

CCD-MONGO

Mongoose based service and CCD controller Also implements the basic CRUD methods

Example CCControllerService<T>

...imports and setup
 
interface User extends mongoose.Document{
    Username:string
}
 
class UserCtrl extends CCServiceController<User>{
    @post('/login')    
    login(req, res){
        //yes, that simple, 
        //model is regulat mongoose model
        return this.model.findOne(req.body); 
    }
}
//the mongoose model needs to be defined
mongoose.Model<User>('User', new mongoose.Schema({
    Username:String
});
 
app.use('/', new UserCtrl('User').router);
app.listen(3000);

Note

If you like to be more structured and have the db methods in a separate class then you can use the CCService<T> class for that.

Package Sidebar

Install

npm i ccd-mongo

Weekly Downloads

4

Version

1.0.4

License

ISC

Last publish

Collaborators

  • stefan.popovski
  • iboshkov
  • ccadm
  • roshan931