Knex resolving empty set after insert
<p>I'm trying to setup a basic database connection in Node using Postgresql and <a href="https://github.com/tgriesser/knex" rel="nofollow">Knex</a>, but I'm having trouble getting what seems like a simple insert to work. I'm basing most of this code on the example code in the Knex github repo. </p>

<p>The issue seems to be that my first insert (where I add the admin user) is resolving an empty set of rows (not really sure since the documentation doesn't contain any info on rows or row sets as far as I can find).</p>

<p>Here is my code:</p>

<pre><code>const knex = require("knex")({
  client: "postgres",
  connection: {
    host     : "127.0.0.1",
    user     : "postgres",
    password : "my password goes here",
    database : "issue-tracker",
    charset  : "utf8"
  }
});

knex.schema
  .dropTableIfExists("tickets")
  .dropTableIfExists("users")
  .createTable("users", createUserTable)
  .createTable("tickets", createTicketTable)
  .then(() =&gt; addTestData())
  .then(() =&gt; console.log("Done"))
  .catch((e) =&gt; console.log(e));

function createUserTable(table) {
  table.increments("id");
  table.string("username").index().unique();
  table.string("password");
  table.timestamps();
}

function createTicketTable(table) {
  table.increments("id");
  table.timestamps();
  table.integer("creator_id").unsigned().references("users.id");
  table.string("text");
}

function addTestData() {
  return Promise.resolve()
    .then(() =&gt;
      knex.insert({username: "admin", password: "password"})
      .into("users")
    )
    .then((rows) =&gt;
      // rows is empty?
      knex.insert({creator_id: rows[0], text: "this is a test"})
      .into("tickets")
    )
    .then(() =&gt;
      knex("users").join("tickets", "users.id", "tickets.creator_id")
      .select("users.id as creator_id", "users.username as creator_name", "tickets.text as text")
    )
    .then(console.log.bind(console));
}
</code></pre>

<p>Any assistance would be much appreciated.</p>