Nodejs Editor validator dbUnique error

Nodejs Editor validator dbUnique error

miyakowilsonmiyakowilson Posts: 2Questions: 1Answers: 0
edited September 2018 in Free community support

I am using Nodejs.Editor 1.7.4.

let editor = new Editor( knex, "Assets2", "assetId")
        .fields(
            new Field('assetId').validator(Validate.dbUnique(  new Validate.Options({
                empty: false,
                message: "assetId must be unique"
                }),
            ))
        );

I am getting the below error:

calling knex without a tableName is deprecated. Use knex.queryBuilder() instead.

error: Sending 500 ("Server Error") response:
 TypeError: host.db(...) is not a function
    at /home/root_sails/server/node_modules/datatables.net-editor-server/dist/va
lidators.js:667:426

The line 667 is

q = host.db()(table)
      .select(column)
      .where({ column: val });

I am using Knex 0.15.2 — 19 Jul, 2018.
Do I need to use older verion of Knex?

Answers

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    Hi,

    Its not a Knex error, but rather one in the Node libraries for Editor I'm afraid. It was fixed here and if you pull in the master version it will work correctly.

    We are currently working on wrapping up 1.8 development which will contain this fix.

    Allan

  • miyakowilsonmiyakowilson Posts: 2Questions: 1Answers: 0

    Thanks for quick fix. It is working now.

This discussion has been closed.