1.0.4 • Published 7 years ago

ccd-mongo v1.0.4

Weekly downloads
7
License
ISC
Repository
github
Last release
7 years ago

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.