When I use the .create(item) method to do an INSERT from the client (within the browser) I see 1 call via websocket or REST go to feathersjs. I see one request go into Feathersjs. For an unknown reason I see 2 rows created in MySql and 2 lines in the log that say: {"message":"after: name_of_service - Method: create","level":"info"}
Using sequelize 4.42.0 and feathers-sequelize 6.0.1
I do not have the issue when running create() from within the server code, only from client.
I found https://github.com/feathersjs-ecosystem/feathers-rethinkdb/issues/80 that looked simular but is for a different DB and the explanation did not fit with MySql.
I switched to MariaDB for other reasons but obviously nothing changed.
I was using FeathersJS v3.x and upgrading to v4.x to see if that would fix it. Nope. As I work around I have been making my own insert methods but it would be nice to use the built in ones.
I tried switching between REST and websocket.
My Hooks:
const { authenticate } = require('@feathersjs/authentication').hooks;
module.exports = {
before: {
all: [ ], // authenticate('jwt') normally use, but deactivated to debug
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
after: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
};
Service:
const createService = require('feathers-sequelize');
const createModel = require('../../models/name_of_service.model');
const hooks = require('./name_of_service.hooks');
module.exports = function (app) {
const Model = createModel(app);
const paginate = app.get('paginate');
const options = {
Model,
paginate: {
default: 100,
max: 2000
}
};
app.use('/name_of_service', createService(options));
const service = app.service('name_of_service');
service.hooks(hooks);
};
I expected it to insert 1 row in MySql table. But got 2. I expected one row in the log for the after hook, but see 2. This has been happening for a couple of months and was thinking, hey, maybe I am not the only one.
this.get().client.service('order_notes').create(obj)and updatesthis.get().client.service('order_notes').patch(this.get().order_notes.id, obj)Client side only sends 1 request.