Hello everyone!What the title says. This is what I want to achieve, using typescript with node and sequelize:export class Controller { Schema: Schema; constructor(schema: Schema) { this.Schema = schema } find(req: Request, res: Response, next: NextFunction) { return this.facade .findWithCount(req.query) .then(collection => res.status(200).json(collection)) .catch(next); } create(req: Request, res: Response, next: NextFunction) { return this.facade .create(req.body) .then(doc => { res.status(201).json(doc); }) .catch(next); } update(req: Request, res: Response, next: NextFunction) { const conditions = { _id: req.params.id }; return this.facade .update(conditions, req.body) .then(doc => { if (!doc) { return next(errors.notFound); } return res.status(200).json(doc); }) .catch(next); } remove(req: Request, res: Response, next: NextFunction) { return this.facade .remove(req.params.id) .then(doc => { if (!doc) { return next(errors.notFound); } return res.status(204).end(); }) .catch(next); } } The problem is, the "Schema" type doesn't exist. Any ideas? Any experience?
Submitted November 08, 2018 at 02:03PM by LmDol
No comments:
Post a Comment