2,498 questions
0
votes
0
answers
63
views
How to handle properly a PostGIS column with Lucid ORM?
I'm building an API using AdonisJS 6, Lucid ORM, knex-postgis, PostgreSQL and PostGIS. I have a posts table that includes a coordinates column of type geometry(Point, 4326).
I want to store ...
1
vote
1
answer
53
views
Knex with MAX producing an error "is not assignable to type"
Currently I have a function like the following:
type StudentGroup {
student_group_id: number,
id: number,
name: number,
student_max_score: number,
}
public async getTopGroupByScores(): Promise<...
0
votes
1
answer
87
views
Knex.js migrate:latest fails with “relation knex_migrations already exists” despite table having been dropped
Background
I’m setting up Knex migrations on a PostgreSQL database running inside WSL2 (Ubuntu). My Node.js/Knex app (also in WSL) connects over the WSL IP to this Postgres instance. Everything ...
0
votes
0
answers
33
views
How to update one single row?
I want to update one single row in database, I tried to put the .limit(1), doesn't seem to work with Postgres.
What would you do in this situation?
list.map(async (i) => {
await kx(...
0
votes
1
answer
46
views
How to use Knex transactions for inserting records with one-to-many relationships?
I'm in a pretty common situation, but I'm struggling to figure out exactly how to achieve what I want by looking at Knex's documentation.
I have a set of entities with a one-to-many relationship to ...
0
votes
1
answer
81
views
Knex query with column name using the "Delete" Reserved Word
Say I have a SQL table named "Customers" that has a column named Delete (used in order to flag the row as deleted without losing the data in case we want to restore it or access logs from it,...
1
vote
0
answers
26
views
How do I use knex with capacitor-community/sqlite plugin?
I'd like to use the capacitor database with its nuances for native platforms, but wrapped in Knex for query builder, is it possible? I didn't find any answer on the internet, even tho ChatGPT gave me ...
0
votes
1
answer
62
views
Getting Error When Trying to Update a Model Using Objection
I am getting this error while trying to update a record in my model using objection.js.
The error I am getting is
Error: An error occurred while executing $setJson method. $setJson method was given an ...
1
vote
0
answers
229
views
Jest unit tests are failing after jest upgrade to 29.7.0 from 27.0.6
I am running some unit tests after a node version upgrade and jest version upgrade in package.json. It is erroring out with
TypeError: Cannot read properties of undefined (reading '_setAdapter')
The ...
0
votes
0
answers
322
views
password authentication failure while connecting to Neon postgres db
I am working on a Nodejs/Express application, and I am trying to connect to a newly created Neon postgres database with knex ORM. My knexfile.js file is below. I have taken the values of all the env ...
0
votes
1
answer
452
views
How to use knex.js the right way in Strapi v5?
I'm diving into Strapi v5, and I noticed it now uses documentId. I want to use Knex.js to insert some records, but I’m a bit lost on how to handle the documentId column.
1
vote
2
answers
499
views
Insert on conflict update not working correctly in postgres
I am using on conflict clause for insert query like this:
insert into "public"."tbl" ("id", "col1", "col2") values ($1, $2, $3) on conflict ("id&...
0
votes
0
answers
123
views
Dpi-1080 connection was closed by ORA-41409
I am getting below when I am running the application, if you restart the node app error will not come, and everything works fine, this error occurs only few times. Dpi-1080 connection was closed by ...
0
votes
1
answer
168
views
Knexjs pooling - set session variables for a connection
I'm working on a nodejs server using Knex.js to connect to a postgres DB.
On some of the tables I've set some RLS policies based on the current session values (app.user_id and app.tenant_id) to ...
0
votes
0
answers
88
views
Handling MySQL BIT Data Type in Knex: Conversion from Buffer to Boolean
i am using knex db with mysql in wappler low code software and i have a column in my table and column name is is_active and it have bit datatype ig it means boolean right ?
so when i use select query ...
1
vote
1
answer
271
views
oracle database does not connect with knex
Good afternoon.
I'm trying to connect an oracle database with knex.
However, I receive an NJS-500 message whenever I try to connect.
I created a nodejs service with knex.
I've tried different ways, ...
1
vote
0
answers
108
views
Knex returning json as string
I am using Knex and nodejs with Sqlite3.
The table structure is as follows:
---------------------------
| Parent |
---------------------------
| - id (PK) |
| - name ...
1
vote
1
answer
97
views
Knex js Making a helper function to get a table's query builder
I'm trying to make my knex code simpler by removing knex.from('table') or knex('table') from my queries to something like table.where(...).select() and by doing this I make sure I'm not pointing to a ...
0
votes
0
answers
162
views
Use custom MySQL2 connection pool into Knex - getting stucked
I am trying to pass a mysql2 connection pool to the Knex client by following the official documentation. However, the query execution seems to get stuck. Even though the insert query successfully ...
0
votes
0
answers
118
views
Error typescript when returning something different than "this" in knex extend function
Problem
I'm trying to extend knex with a function that would return something that is not the queryBuilder instance. I guess the same way that .toSQL() returns an object that is not the queryBuilder.
...
0
votes
1
answer
44
views
How do i validate a duplicate email input using knex?
I'm building an app with node.js knex.js typescript zod and fastify, im trying to validate the emails so that when an email is inserted on the user registration, if it is a duplicate it throws status ...
0
votes
1
answer
268
views
Using knex's onConflict().merge() is creating duplicate rows in my db?
Exactly as the title says. I've got a simple transaction that should determine whether a record exists already, and update it if an image url has changed. Otherwise, create a new record. It looks like ...
0
votes
1
answer
293
views
Unable to use system-assigned identity with Knex: ConnectionError: Login failed for user ''
I'm encountering an issue while trying to connect to a Microsoft SQL Server database using Knex with system-assigned identity. Despite configuring Knex to utilize system-assigned identity for ...
0
votes
1
answer
148
views
How to efficiently insert or upsert a single column in PostgreSQL for optimal performance?
I'm seeking guidance on how to use PostgreSQL to update multiple rows in a specific column. I’m particularly interested in methods that offer optimal performance. Any help would be greatly appreciated
...
1
vote
1
answer
40
views
Building knex innerJoin with Postgres JSONB "?" operator?
I want to create a query like this with knex:
select "data"."parent"."name"
from "data"."parent"
inner join "data"."child"...
0
votes
0
answers
118
views
Knex not compiling Date to ISO string
I am using knex.js with a postgresql database.
I am looking into replacing moment.js with date-fns in my codebase and I am running into a really odd situation with the formatting of queries.
We are ...
0
votes
1
answer
163
views
How to force specified alias case when using object syntax in .select
I am using knex.js with OracleDB, attempting to use the object syntax in a select with query builder, like below.
knex.select({ currentDate: "SYSDATE"}).from("dual")
While this ...
0
votes
0
answers
146
views
Knex migration not working with node on windows
I'm trying to run the command npm run update:db, and I'm having errors. Below is what the command runs (as it would appear in the package.json files):
"update:db": "cd ../db && ...
2
votes
2
answers
4k
views
Knex timeout - what is the best approach to fix it?
I have an application backend hosted on Amazon Linux AMI, which I set up approximately 6 months ago. Initially, I used Node.js 17.x without much consideration as it was part of my AWS AMI setup.
...
0
votes
1
answer
357
views
Error when launching signed and notarized app - JavaScript error occurred in the main process
When launching an electronjs app that has been osx signed and notarized with electron-forge I get the following error:
Uncaught Exception:
Error: Knex: run
$ npm install sqlite3 --save
dlopen(/var/...
0
votes
1
answer
991
views
Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call? [2024]
I'm encountering a KnexTimeoutError when attempting to deploy my Node.js application's database changes using a series of npm scripts that utilize Knex migrations. My goal is to rollback all ...
4
votes
1
answer
449
views
Handling Concurrent Transactions with Knex.js and PostgreSQL
I'm working on a Node.js application using knex.js for database operations with PostgreSQL. My database has a users table with columns id and credits. The isolation level of my PostgreSQL database is ...
0
votes
1
answer
763
views
How do I access the underlying better-sqlite3 from a knex.js connection?
I'm wondering how I might get ahold of the better-sqlite3 connection that knex is using so that I can use better-sqlite3 methods directly on a knex connection. Specifically I'd like to use better-...
1
vote
2
answers
82
views
How to return only values from SELECT and WHERE IN query?
I have the following table - orders:
id
value
price
amount
2
'orange'
$12
7
8
'yellow'
$14
29
5
'green'
$17
9
I have to perform SELECT query with WHERE IN clause
SELECT value FROM order WHERE id IN (2,...
2
votes
0
answers
123
views
Trigger-based audit logging do not function properly with current_setting
I am developing an Apollo GraphQL API with Postgres as database system.
I have the following 4 Knex migrations for setting up a trigger-based audit log system, where the last snippet illustrates how ...
0
votes
2
answers
243
views
Cloud SQL with Firebase Functions V2
I'm receiving connect ENOENT /cloudsql/<proj>:us-west1:<instance>/.s.PGSQL.5432 When connecting to a Cloud SQL instance of PostgreSQL 15 from a Firebase V2 Callable function. I've looked ...
0
votes
1
answer
231
views
Knexfile not getting .env variables during command line migration
I am using Knex with a MySQL database and am trying to migrate my tables using npx knex migrate:latest. However, when I run the command I am getting the following error: "Access denied for user ''...
3
votes
0
answers
639
views
How to make Knex automatically close connections that are idle in transaction?
In our codebase we sometimes have accidental transaction leaks where a transaction is opened with Knex but never closed. As a safety net we want to introduce a way to automatically close connections ...
0
votes
1
answer
300
views
How do I GROUP BY the first expression of a UNION ALL query in Knex.JS?
I have a table entries linked with another table categories.
There is also a column is_marked of type BOOLEAN.
The user may want to see the marked entries separately, so I wish to show the count of
...
0
votes
2
answers
84
views
showing error [symbol.iterator()] in ts generics in knex query
const [user]: T = await db("users").insert(data).returning("*");
// error:Type 'T' must have a '[Symbol.iterator]()' method that returns an iterator.
My knex query typescript ...
0
votes
0
answers
274
views
How to mock the Knex in a test file of nestjs
I am developing an API in Nest using Knex:
import { Injectable, NotFoundException } from '@nestjs/common'
import { InjectKnex, Knex } from 'nestjs-knex'
import { ICreatePersonData, IUpdatePersonData, ...
0
votes
0
answers
98
views
Node.js program using knex and google cloud sql connector doesnt exit
const Knex = require('knex');
const { Connector } = require('@google-cloud/cloud-sql-connector');
const connectWithConnector = async () => {
const connector = new Connector();
const ...
0
votes
1
answer
315
views
Knex tries to use sqlite3 when already using mysql2
I'm trying to run some operations on a Node Typescript project with knex. It is already configured and when using knex-cli to create or run migrations (just as an example) it works perfectly fine.
The ...
0
votes
0
answers
966
views
Why ami I getting TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
We are getting Knex timeout error mostly during high traffic in production with postgresql database. The knex config is as follows:
module.exports = {
client: 'pg',
connection:
process.env....
0
votes
0
answers
174
views
Adapting Knex Configuration from SQLite to PostgreSQL
I'm facing an issue when trying to deploy a Node.js API that uses Knex, Express, and the SQLite database on Vercel. Since Vercel doesn't support SQLite, I'm seeking guidance on how to transform my ...
-2
votes
1
answer
2k
views
error: no pg_hba.conf entry for host "93.143.119.96", user "postgres", database "UMA_Metkovic", no encryption
I have my local database. So i made aws databse, and migrated data following this yt video https://www.youtube.com/watch?v=Vi44UHVYWEg&t=8s&pp=ygUUbG9jYWwgZGF0YWJzZSB0byBhd3M%3D
My connection ...
0
votes
1
answer
555
views
Strapi Controller Not Populating Nested Repeatable Component
I'm using Strapi v4 and facing an issue with populating a nested repeatable component in my API response. I have a repeatable component faq_item inside another component faqs. However, when I attempt ...
0
votes
2
answers
414
views
Pagination problem using knex and objection.js
My pagination works just fine without relations.
But if I add images relation, I loose one post row.
If I use only 1 image per post, no problem.
I don't think the problem is with my join table, ...
0
votes
1
answer
99
views
Can't mock/stub knex methods
On my code I have something like:
const getItem = async (itemId) => {
const item = await knex('item').where('id', itemId).first();
console.log(item);
};
And on my test file:
sinon.stub(knex, '...
1
vote
2
answers
49
views
Use one combined property in knex to query two separate columns in PostgreSQL
I want to query items from Postgres database with knex. In the database, I have two separate columns first_name and last_name, but I need to compare them both to a single value which is formatted &...