I downloaded editor samples, and in controller json.js
, I write two routes, they all used join tables.
Here is the first one, it works fine on new, editing and deleting.
// using `public` schema
router.all('/api/join', async function(req, res) {
let editor = new Editor(db, 'users')
.debug(true)
.fields(
new Field('users.first_name'),
new Field('users.last_name'),
new Field('users.phone'),
new Field('users.site').options(
new Options().table('sites as sites1').value('id').label('name')
),
new Field('sites.name')
)
.leftJoin('sites as sites', 'sites.id', '=', 'users.site');
let e2 = await editor.process(req.body);
res.json(editor.data());
});
And this one only works on new and editing.On deleting side, it seems the SQL not called.
// using `sandbox1` schema
router.all('/api/join2', async function(req, res) {
let editor = new Editor(db, 'sandbox1.users as users')
.fields(
new Field('users.first_name'),
new Field('users.last_name'),
new Field('users.phone'),
new Field('users.site')
.options(
new Options().table('sandbox1.sites as sites1').value('id').label('name')
),
new Field('sites.name')
)
.leftJoin('sandbox1.sites as sites', 'sites.id', '=', 'users.site')
await editor.process(req.body);
res.json(editor.data());
});
I use datatables.net-editor-server
1.8.1
.
And I am sure the font-end send the right data to back-end.
Any suggestion for me?