@victorlizarraga/generic-consumers

Generic consumers for pubsub

Usage no npm install needed!

<script type="module">
  import victorlizarragaGenericConsumers from 'https://cdn.skypack.dev/@victorlizarraga/generic-consumers';
</script>

README

Generic consumers

Examples

//consumerExample.js
const genericConsumers = require('@victorlizarraga/generic-consumers');
const { app } = require('@carlosbajo/micro');

module.exports = {
  getAll: genericConsumers.findAll(app, 'modelExample'),

  //input req.arg._id
  getById: genericConsumers.findOneById(app, 'modelExample'),

  //input req.arg._id
  deleteById: genericConsumers.deleteById(app, 'modelExample'),

  //input req.arg
  insert: genericConsumers.insert(app, 'modelExample'),
  //input req.arg
  update: genericConsumers.update(app, 'modelExample'),

  //input req.arg.testId
  //Model must have property 'testId'
  findByTestId: genercConsumers.findByProps(app, 'modelExample', ['testId']),

  //input req.arg.testId
  //Model must have property 'testId'
  findOneByTestId: genercConsumers.findOneByProps(app, 'modelExample', [
    'testId'
  ])
};