hasTable() doesn't resolve with a boolean
See original GitHub issueHi, I am using knex schema builder to create the database tables
// create categories table
db.hasTable('categories').then(function (exists) {
debug(exists)
if ( exists ) return
return db.createTable('categories', function (table) {
table.increments('id')
table.string('name').notNullable()
table.string('slug').notNullable().index()
})
}).then(function () { debug("Table `categories` created") })
// create tags table
db.hasTable('tags').then(function (exists) {
debug(exists)
if ( exists ) return
return db.createTable('tags', function (table) {
table.increments('id')
table.string('name').notNullable()
table.string('slug').notNullable().index()
})
}).then(function () { debug("Table `tags` created") })
after debugging, exists
is an array instead of a boolean, below the output of the console
database [ true, false ] +0ms <=
database [ true, false ] +4ms
database Table `categories` created +2ms
database Table `tags` created +0ms
true means that the table categories already exist, tags does not.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
hasTable() doesn't resolve with a boolean · Issue #1509 · knex ...
Hi, I am using knex schema builder to create the database tables // create categories table db.hasTable('categories').then(function (exists) ...
Read more >hash table does not count values correctly - Stack Overflow
Here, i'm trying to implement a chaining hash table. In here when I enter a same key, it joins with existing key and...
Read more >Java Hashtable class - HowToDoInJava
Java Hashtable class is an implementation of hash table data structure. ... boolean isEmpty() : It returns true if the hashtable is empty; ......
Read more >Everything you wanted to know about hashtables - PowerShell
A hashtable is a data structure, much like an array, except you store each value (object) using a key. It's a basic key/value...
Read more >An Introduction to java.util.Hashtable Class - Baeldung
A guide to understanding the Hashtable structure in Java. ... Any Java object inherits the hashCode() method which returns an int value.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m pretty sure this is caused by reusing the
schema
reference rather than instantianting a new reference each time.For example this:
The schema reference is still just a query builder. So everytime
.then
is called, it will run the queries from the builder chain.Doing this should solve the ‘strangeness’:
Or even better:
I wouldn’t consider this a bug. @elhigu What do you think?
CC @tgriesser @jurko-gospodnetic
I stumbled with the same issue during the last 2 hours, I find It good as an optimización but should be shown in the docs. Better, has two methods, hasTable() that always returns a Booleana, and hasTables() that always returns an Array of Booleana