mirror of
https://github.com/knex/knex.git
synced 2026-01-06 12:07:07 +00:00
hasColumn docs, mysql hasColumn fix, fixes #87
This commit is contained in:
parent
edd41aa249
commit
3ebc4cbb63
@ -16,6 +16,7 @@ exports.schemaGrammar = _.defaults({
|
||||
if (builder.type === 'tableExists') {
|
||||
bindings.unshift(builder.client.connectionSettings.database);
|
||||
}
|
||||
if (builder.type === 'columnExists') bindings.shift();
|
||||
return bindings;
|
||||
},
|
||||
|
||||
|
||||
16
index.html
16
index.html
@ -255,11 +255,11 @@
|
||||
<li>– <a href="#Schema-createTable">createTable</a></li>
|
||||
<li>– <a href="#Schema-renameTable">renameTable</a></li>
|
||||
<li>– <a href="#Schema-dropTable">dropTable</a></li>
|
||||
<li>– <a href="#Schema-hasColumn">hasColumn</a></li>
|
||||
<li>– <a href="#Schema-hasTable">hasTable</a></li>
|
||||
<li>– <a href="#Schema-dropTableIfExists">dropTableIfExists</a></li>
|
||||
<li>– <a href="#Schema-table">table</a></li>
|
||||
<li><b><a href="#Schema-Building">Schema Building:</a></b></li>
|
||||
<li>– <a href="#Schema-hasColumn">hasColumn</a></li>
|
||||
<li>– <a href="#Schema-dropColumn">dropColumn</a></li>
|
||||
<li>– <a href="#Schema-dropColumns">dropColumns</a></li>
|
||||
<li>– <a href="#Schema-renameColumn">renameColumn</a></li>
|
||||
@ -1046,6 +1046,13 @@ knex.schema.hasTable('users').then(function(exists) {
|
||||
});
|
||||
</pre>
|
||||
|
||||
<p id="Schema-hasColumn">
|
||||
<b class="header">hasColumn</b><code>knex.schema.hasColumn(tableName, columnName)</code>
|
||||
<br />
|
||||
Checks if a column exists in the current table, resolves the promise with a boolean, <tt>true</tt>
|
||||
if the column exists, <tt>false</tt> otherwise.
|
||||
</p>
|
||||
|
||||
<p id="Schema-dropTableIfExists">
|
||||
<b class="header">dropTableIfExists</b><code>knex.schema.dropTableIfExists(tableName)</code>
|
||||
<br />
|
||||
@ -1071,13 +1078,6 @@ knex.schema.table('users', function (table) {
|
||||
|
||||
<h3 id="Schema-Building">Schema Building:</h3>
|
||||
|
||||
<p id="Schema-hasColumn">
|
||||
<b class="header">hasColumn</b><code>table.hasColumn(name)</code>
|
||||
<br />
|
||||
Checks if a column exists in the current table, resolves the promise with a boolean, <tt>true</tt>
|
||||
if the column exists, <tt>false</tt> otherwise.
|
||||
</p>
|
||||
|
||||
<p id="Schema-dropColumn">
|
||||
<b class="header">dropColumn</b><code>table.dropColumn(name)</code>
|
||||
<br />
|
||||
|
||||
@ -129,7 +129,11 @@ module.exports = function(knex) {
|
||||
|
||||
it('checks whether a column exists, resolving with a boolean', function() {
|
||||
|
||||
return knex.schema.hasColumn('accounts', 'first_name');
|
||||
return knex.schema.hasColumn('accounts', 'first_name').then(function(exists) {
|
||||
|
||||
expect(exists).to.be.true;
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user