gpt4 book ai didi

javascript - Feathers JS - 创建多个条目 - 愚蠢的问题

转载 作者:行者123 更新时间:2023-12-05 00:37:47 26 4
gpt4 key购买 nike

按照文档,我意识到有一个允许批量创建的选项,但我不明白在哪里以及如何设置该选项,这里是代码:

// 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);
};

先感谢您。

最佳答案

该选项被添加到 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);
};

关于javascript - Feathers JS - 创建多个条目 - 愚蠢的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55238079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com