Deleting did not working in Node server side

Deleting did not working in Node server side

codinggirlcodinggirl Posts: 1Questions: 1Answers: 0

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?

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Could you try adding debug: true into your Knex configuration object please and then run the server and try to delete a row. What does the console show?

    Another thing to try would be to remove the aliases and just use the table names directly.

    Allan

This discussion has been closed.