Convert a mysql query to its equivalent Knex query
P粉412533525
P粉412533525 2024-02-26 19:06:08
0
1
299

I'm trying to convert my mysql query to its equivalent Knex query

This is the query Create table test ( id INT UNSIGNED NOT NULL AUTO_INCRMENT, name VARCHAR(100), unique (id) ) AUTO_INCRMENT = 1001;

So basically I want to create a table with a column called "id" that is of type autoincrement and whose values ​​start at 1001.

I want it's equivalent to the Knex query. Tried browsing the documentation but couldn't get much help.

P粉412533525
P粉412533525

reply all(1)
P粉098417223

The Knex.js architecture from SQL is like :

knex.schema.createTable('test', function(table) {
  table.increments('id').unsigned().notNullable().unique().defaultTo(1001);
  table.string('name', 100);
})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template