How to use the schema function from knex
Find comprehensive JavaScript knex.schema code examples handpicked from public code repositorys.
GitHub: ais-one/cookbook
29 30 31 32 33 34 35 36 37 38
await knex('test_table').truncate() console.log('See Transaction...') await knex.transaction(async trx => { await knex('test_table').insert({ name: 'aa' }).transacting(trx) // await knex.schema.raw('SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;') let rv = await knex.select().from('test_table') console.log(rv) await knex('test_table').insert({ name: 'bb' }).transacting(trx)
116
447
29
+ 11 other calls in file
GitHub: LiskHQ/lisk-service
24 25 26 27 28 29 30 31 32 33 34 35 36
const tablePool = {}; const loadSchema = async (knex, tableName, tableConfig) => { const { primaryKey, charset, schema, indexes } = tableConfig; if (await knex.schema.hasTable(tableName)) return knex; await knex.schema .createTable(tableName, table => { if (charset) table.charset(charset);
17
28
0
+ 19 other calls in file
80 81 82 83 84 85 86 87 88 89 90
console.log(data); knex.destroy(); } async function createTable() { // await knex.schema.createTable('users2', (table) => { // table.increments(); // table.string('name'); // table.timestamps(); // });
0
0
1
+ 23 other calls in file
GitHub: GRAVEDDIGER/passportConfig
13 14 15 16 17 18 19 20 21 22
//OtroMas.createUser({username:"aabadin@gmail.com2",password:"111",isVerified:true,mail:"aabadin@gmail.com" }).then(()=>console.log("fin")) //OtroMas.findById(2,(e,res)=>console.log(res,e)) OtroMas.findByUserName("aabadin@gmail.com").then((res)=>console.log(res)) OtroMas.returnFields().then((res)=>console.log(res)) // console.log(OtroMas.db("users"),"USERS") // knex.schema.alterTable("goa",table=>{ // table.dropColumn("password") // }).then(()=>console.log("borrado")) //const DAO =new SqlDAO(tabla1,"localSchema") // DAO.hasField("username").then(e=>console.log(e))
0
0
0
GitHub: nickmullen/random-users
14 15 16 17 18 19 20 21 22 23 24 25
const { faker } = require("@faker-js/faker"); const { toNamespacedPath } = require("path"); const insertDummyData = async () => { await knex.schema.dropTableIfExists("users"); await knex.schema.createTable("users", (table) => { table.increments("id"); table.string("first_name", 50); table.string("last_name", 50);
0
0
0
+ 3 other calls in file