Feathers JS - Создание нескольких записей - тупой вопрос - PullRequest
0 голосов
/ 19 марта 2019

следуя документации, я понимаю, что есть возможность разрешить массовое создание, но я не понимаю, где и как установить эту опцию, здесь код:

// Initializes the `test` service on path `/test`
const createService = require('feathers-sequelize');
const createModel = require('../../models/test.model');
const hooks = require('./test.hooks');

module.exports = function (app) {
  const Model = createModel(app);
  const paginate = app.get('paginate');


//Where to put the multi option???
  const options = {
    Model,
    paginate
  };

  // Initialize our service with any options it requires
  app.use('/test', createService(options));

  // Get our initialized service so that we can register hooks
  const service = app.service('test');

  service.hooks(hooks);
};

Заранее спасибо.

1 Ответ

1 голос
/ 19 марта 2019

Опция добавлена ​​к объекту options:

// Initializes the `test` service on path `/test`
const createService = require('feathers-sequelize');
const createModel = require('../../models/test.model');
const hooks = require('./test.hooks');

module.exports = function (app) {
  const Model = createModel(app);
  const paginate = app.get('paginate');


//Where to put the multi option???
  const options = {
    Model,
    paginate,
    multi: [ 'create' ] // list of method names
    // or for everything
    // multi: true 
  };

  // Initialize our service with any options it requires
  app.use('/test', createService(options));

  // Get our initialized service so that we can register hooks
  const service = app.service('test');

  service.hooks(hooks);
};
...