Skip to content

A way to automate mongoose model methods mapping #38

@vladyslav-dotsenko

Description

@vladyslav-dotsenko

It would be pretty cool to make restifyMongoose resource support custom model methods and improove restifyMongoose::serve function to automatically generate api endpoint for those methods.
For example:
When we have model...

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const _schema = new Schema({
  title:  String,
  toggle: { type: Boolean, default: false }
});

_schema.methods.switch = function () {
  this.toggle = !this.toggle;
  this.save();
};

var Toggler = mongoose.model('Toggler', _schema);

... it would be great to generate endpoint /Toggler/:id/switch wich will call appropriate method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions