knex.js

Removing Migrations With Knex.js In My Node.js Application

无人久伴 提交于 2020-05-26 11:09:50
问题 I am trying to get knex working in my node.js application. I was following a tutorial and at some point created a table but could not repeat the process. I removed the table and deleted all the migrations folders. At tis point I started over but after creating a new migration and then running knex migrate:latest I get an error saying the migration directory is corrupt because the original migration I had is missing. I was under the impression that if the file is missing it should not know it

Removing Migrations With Knex.js In My Node.js Application

本小妞迷上赌 提交于 2020-05-26 11:09:07
问题 I am trying to get knex working in my node.js application. I was following a tutorial and at some point created a table but could not repeat the process. I removed the table and deleted all the migrations folders. At tis point I started over but after creating a new migration and then running knex migrate:latest I get an error saying the migration directory is corrupt because the original migration I had is missing. I was under the impression that if the file is missing it should not know it

Error: Undefined binding(s) detected when compiling SELECT from Bookshelf.js save()

允我心安 提交于 2020-05-17 06:42:15
问题 While testing a Bookshelf model insert using the oracledb client (versions bellow), I'm having an strange error. I've tested same code with mysql , pg and sqlite3 clients with no problem in this operation. My model is this: Promotion = bookshelf.model('Promotion', { tableName: 'promotions' }) And the action that triggered the error is this: Promotion.forge({image:"image","featured":false,"price":"2.33","name":"name","description":"description"}).save(null, { method:'insert' }) The insertion

knex postgres returns strings for numeric/decimal values

对着背影说爱祢 提交于 2020-05-15 11:02:42
问题 I have a table with column table.decimal('some_column', 30,15) which on postgres is numeric(30,15) When I run a knex.raw('select some_column from some_table') from node, the response I get in rows is like: some_column: "5.000000000000000" some_column: "10.000000000000000" What really pointed me to this is that I do something like firstValue>lastValue I end up with a true response so that makes me think that these are returned as strings and not as numbers. Any way to override this behavior?

where to destroy knex connection

大憨熊 提交于 2020-05-13 05:07:12
问题 I'm using knex with pg. I have a project similar as following. dbClient.js const dbClient = require('knex')({ client: 'pg', connection: { host: '127.0.0.1', user: 'user', password: 'password', database: 'staging', port: '5431' } }) module.exports = dbClient libs.js const knex = require('./dbClient.js') async function doThis(email) { const last = await knex('users').where({email}).first('last_name').then(res => res.last_name) // knex.destroy() return last } async function doThat(email) { const

Updating a Morph-One Associated model and receiving “Unhandled rejection Error”

℡╲_俬逩灬. 提交于 2020-04-30 06:38:06
问题 Code Preferred way this.related('title').save({value: input}); But as this line is cut and pasted from a middle of some abstract class, below is a more decoupled way of directly reproducing the same error message. Alternative Implementation let title = await book.related('title'); title.set({value: inputs.title}); title.save().then( (model) => {} ); Error message Unhandled rejection Error: Undefined binding(s) detected when compiling SELECT. Undefined column(s): [titles.titleable_id] query:

Expect JSON Output not return in node.js output

妖精的绣舞 提交于 2020-03-25 22:59:12
问题 I have a table called user_feedbacks, For type we have 4 default values - 1-Suggestion, 2-Request, 3-Damage Report, 4-Incident For status we have 3 default values - 0-open, 1-in progress, 2-closed I want to show under each type for each status, count of records like below [Required Output] , { "status": "success", "code": 200, "data": { "1"(Type): { "0" (status): 20, (total) "1": 19, "2": 28 }, "2": { "0": 20, "1": 19, "2": 28 }, "3": { "0": 20, "1": 19, "2": 28 }, "4": { "0": 20, "1": 19, "2

Expect JSON Output not return in node.js output

为君一笑 提交于 2020-03-25 22:57:41
问题 I have a table called user_feedbacks, For type we have 4 default values - 1-Suggestion, 2-Request, 3-Damage Report, 4-Incident For status we have 3 default values - 0-open, 1-in progress, 2-closed I want to show under each type for each status, count of records like below [Required Output] , { "status": "success", "code": 200, "data": { "1"(Type): { "0" (status): 20, (total) "1": 19, "2": 28 }, "2": { "0": 20, "1": 19, "2": 28 }, "3": { "0": 20, "1": 19, "2": 28 }, "4": { "0": 20, "1": 19, "2

How to prevent Knex.js from running a query object when returning it from an async function?

孤街醉人 提交于 2020-03-02 05:42:24
问题 I have a node.js backend that constructs DB queries dynamically from various inputs using Knex.js. Some of the inputs need to be processed asynchronously. My problem is, that I can't return a knex query object from an async function (or of course in a Promise resolve function) because this triggers the execution of the query. Currently I need to process all my async inputs before handing them to the query building functions but that really limits their composability. Is there a way to prevent

How to prevent Knex.js from running a query object when returning it from an async function?

爱⌒轻易说出口 提交于 2020-03-02 05:39:41
问题 I have a node.js backend that constructs DB queries dynamically from various inputs using Knex.js. Some of the inputs need to be processed asynchronously. My problem is, that I can't return a knex query object from an async function (or of course in a Promise resolve function) because this triggers the execution of the query. Currently I need to process all my async inputs before handing them to the query building functions but that really limits their composability. Is there a way to prevent