How to use the table function from knex

Find comprehensive JavaScript knex.table code examples handpicked from public code repositorys.

800
801
802
803
804
805
806
807
808
809
// //select * from "users" inner join "accounts" on "accounts"."type" = "admin"

//const data = await knex.from('users').innerJoin('accounts','users.id','accounts.user_id');
//select * from "users" inner join "accounts" on "users"."id" = "accounts"."user_id"

// const data = await knex.table('users').innerJoin('accounts', 'users.id', '=', 'accounts.user_id');
// //select * from "users" inner join "accounts" on "users"."id" = "accounts"."user_id"

// const data = await knex('users').innerJoin('accounts',  (qb) => {
//   qb.on('accounts.id', '=', 'users.account_id')
fork icon0
star icon0
watch icon1

+ 2 other calls in file

59
60
61
62
63
64
65
66
67
68
69
  console.log("Categories done!");
};


const createTags = async () => {
  for (let index = 0; index < 10000; index++) {
    await knex.table("tags").insert({
      name: capitalize(faker.random.word()),
      created_at: new Date(),
      updated_at: new Date(),
    });
fork icon0
star icon0
watch icon0

+ 11 other calls in file

8
9
10
11
12
13
14
15
16
17
18
19
app.listen(port, () => console.log(`listening on port: ${port}`));




// Base route
app.get('/', async (request, response) => {
  const getModel = () => database.table('users');
  const totalCount = await getModel().count();
  const usersCount = totalCount[0]['count'];
  var message = 'Server running at port 9000 with ' + usersCount + ' users'
  response.send(message);
fork icon0
star icon0
watch icon0