Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
78 views

Using Bookshelf Models and knex, How can I fetch data from first table withRelated to second table with a condition of data related to third table

I am using bookshelf with knex query builder. I have 3 sql tables: forms, users, exams and their related models: formsModel,usersModel, examsModel. I am successfully fetching data from forms table ...
UdayanBKamble's user avatar
0 votes
1 answer
112 views

can't create view in bookshelf knex. getting migration error as: schema.createView is not a function

I wish to create view that collectively shows data from multiple tables in my mysql database. Project is nodeJS based. npm versions using "bookshelf": "^0.14.2" & "knex&...
UdayanBKamble's user avatar
1 vote
0 answers
263 views

Strapi v4 Bookshelf query builder similar to v3

So we’ve been using strapi v3 for quite many years and are now migrating our app to v4. In v3 we could use bookshelf query builder to build our apis as per the v3 docs here: https://docs-v3.strapi.io/...
Ali Raza Sherazi's user avatar
0 votes
0 answers
212 views

Is there an actively maintained replacement for Bookshelf.js?

The most recent Bookshelf.js version is over two years old. What is the recommended replacement?
Nikolay Yordanov's user avatar
2 votes
0 answers
240 views

How to add nolock condition in the bookshelf or knex nodejs before fetch

I am using a bookshelf and wanted to add the default value as WITH(NO LOCK) Update: is it possible to achieve this using knex as I have that library installed in my code? User.forge() ....
app's user avatar
  • 207
0 votes
1 answer
141 views

How to update primary key and it's references to other tables at the same time

I have a main table with primary key as 'main_id'. This 'main_id' is being used a foreign key in two tables : 'sub_table1', 'sub_table2' I have a requirement where I need to change the 'main_id' and ...
warlordofhogwarts's user avatar
1 vote
1 answer
147 views

How can I hide certain attribute from response with Bookshelf?

I am building a simple REST API. When registering a new user, my API returns: { "status": "success", "data": { "email": "[email protected]&...
orangecheese's user avatar
0 votes
1 answer
883 views

Filtering items by relation using knex query

I'm trying to filter items by relation using a knex query. I'm almost there (I think) but struggling a little and could use some help as this is new to me. I have a list of users who are following ...
Ashmore11's user avatar
  • 188
0 votes
2 answers
327 views

How to us CASE WHEN aggregation with bookshelf

I'm working with PostgreSQL and bookshelf and trying to run a simple SQL query in order to get multiple counts in a single query. This query look like: SELECT SUM(CASE WHEN date_last_check > (now() ...
Adrien DEBLOCK's user avatar
1 vote
0 answers
59 views

How to join two tables, apply where on both tables , apply pagination with bookshelf node js

I have two tables mentioned below: Reports Id |status 1 |Active Reports_details Id| Cntry| State | City 1 | IN | UP | Delhi 1 | US | Texas | Salt lake Now my requirement is Select distinct r....
pRiyanKa_Rathore's user avatar
1 vote
0 answers
384 views

Strapi: trouble populating multi-valued attribute for nested relation

I have a collection called dish-category which contains many dishes, and a dish collection that contains many dish-options (another collection). the list of dishes from each dish-category is ...
Christopher's user avatar
1 vote
1 answer
2k views

How to deep fetch In Strapi cms compnents?

I have the following user API from Strapi cms to which I want to deep fetch address component(repeatable component). So, what I want to fetch is the user whose address is 63 Southlands Road... I ...
Mai Rich's user avatar
1 vote
2 answers
2k views

Strapi filter by many to many relation

I have two tables in postgresql in strapi: goods and labels Goods: id | title --------- 1 | some name 2 | some name 2 3 | some name 4 ………………… Labels id | title ------------ 1 | some label 1 2 | some ...
Alex Mir's user avatar
0 votes
1 answer
507 views

Convert Raw SQL to Bookshelf/Knex

I'm trying to convert a simple raw SQL to use Bookshelf/Knex in JavaScript: Original SQL: select * from o where o.id = 1 or o.id = 2 and (o.is_a = true or o.is_b = true) and o.status = 'good'; I've ...
Ash's user avatar
  • 43
1 vote
1 answer
158 views

MySQL degrading performance over many (~10-100K) short select queries

I'm currently building an app on Node with MySQL database where on the initial run I have to calculate ~250M items. Each calculation takes 3 SELECT statements. I'm testing with a couple of thousands ...
Helvijs Sebris's user avatar
5 votes
1 answer
8k views

How to use a uuid as default ID with postgres?

Currently in the process of migrating to to postgres after the announcement about dropping mongodb, Just noticed that the ID's are just numbers and auto-incremented. I have tried: Setting the default ...
Sid's user avatar
  • 1,014
0 votes
0 answers
144 views

TypeError: ModelName.forge(...).destroy is not a function

I'm working on a API using node, where ModelName means the model built using bookshelf.js like this: const bookshelf = require('./bookshelf') const Intake = require('./intake') const ModelName = ...
Julissa DC's user avatar
1 vote
0 answers
167 views

How to update data fields on the server-side?

How I write a script and update a collection field from my server? I need to update a field of 100 users. I was wondering if I can change them from the server, instead of sending update mutations over ...
Cem Kaan's user avatar
  • 2,226
1 vote
1 answer
208 views

How do I select specific column data to be displayed in my bookshelf model belongsTo relationship in Nodejs?

This is a contrived example of what I would like to do: Suppose I have a database of teams and players: team: ->id ->color ->rank ->division player: ->id ->team_id ->number -&...
user12313's user avatar
1 vote
1 answer
290 views

Bookshelf.js withRelated TypeScript error

So, in my app I have categories and articles that are interrelated. At first I retrieve all of categories and there are articles inside each of them. The problem is I wanna filter both categories and ...
Aleksei V.'s user avatar
2 votes
1 answer
3k views

Strapi update many-to-many relationships in strapi?

I have two collection types in Strapi, created with many-to-many relation. What is the proper way to write a custom query to update only the relation? **user** id name 1 user1 **store** id ...
Yen Sheng's user avatar
  • 725
1 vote
2 answers
2k views

React: Converting DateTime from Database within my Axios Call

I'm trying to figure out how to convert my database's dates with LUXON within the axios call, is this possible or should I change it within the database data itself? Here's my code below: const ...
PrinceJelly's user avatar
0 votes
1 answer
91 views

Only 1 orWhere in Bookshelf query?

I have the following Bookshelf method in my controller: const transaction = await Transaction.query({ where: { status: "paid", id: req.params.transaction_id }, orWhere: { status: &...
Nick's user avatar
  • 3,070
0 votes
1 answer
449 views

Bookshelfjs destroy where and where

Is it safe to do this? await MyModel.where(toSnakeCase(userID), user.id). where(toSnakeCase(shopId), user.shopId).destroy(); within bookshelf model. I would like to do a delete where ...
BizMAN's user avatar
  • 95
1 vote
0 answers
104 views

Bookshelf.js fetchAll() performance

I have +20k records in my MySQL table that uses InnoDB engine and utf8_general comparison. When I am trying to fetch all the data using Bookshelf.js fetchAll() it takes around 6 seconds. I tried using ...
Rent0's user avatar
  • 11
0 votes
1 answer
110 views

How to join/populate 3 tables with Bookshelf in Node.js

[This is different from already asked question] I have 3 tables book, chapter, paragraph. Book related to chapter.(one to many) Chapter related to Paragraph(one to many) How can I query Book and get ...
Rohan Gulati's user avatar
0 votes
0 answers
74 views

How to include deleted items in query BookshelfJS?

How to include deleted items in query BookshelfJS? I tried this query User.forge().where('deleted_at', "IS NOT", null).fetchAll(); In the debugging output select * from users where `...
Yves Gonzaga's user avatar
  • 1,048
0 votes
0 answers
17 views

Bookshelf.js return promise pending on fetchAll [duplicate]

i am new at JS and Node. I am trying to make a task list in Expressjs. I have a bookshlef.js ODM. I traing to get all tasks from DB in function getAllTasks : module.exports.getAllTasks = async ...
dkrakowski's user avatar
0 votes
1 answer
439 views

How do I get data from currency exchange rates API and save into MSSql database with Nodejs? [closed]

I want to fetch data from https://openexchangerates.org/ API once I get the data from API I want to save API data into MSSql database and want to schedule at 10am Anyone can provide similar example I ...
h d's user avatar
  • 53
1 vote
1 answer
618 views

Bookshelf andWhere / orWhere syntax problem

await bookshelf .model('User') .where({ org_id: this.get('id'), isAdministrator: 1 }) .fetchAll() .then... This works and selects those records with a certain org_id and for which ...
Marty's user avatar
  • 2,214
2 votes
1 answer
401 views

Bookshelf.js relation with foreign key from a property in json

I have 2 models Book: id, name, data (json) Author: id, name I want to extend Book model with method author which return the author when query withRelated. This could be easy to achieve with below ...
hgb123's user avatar
  • 14.8k
1 vote
1 answer
830 views

Extending bookshelf model with typescript causes error

I have instantiated bookshelf like this in a configuration file: // irrelevant code omitted const knex = Knex(knexfile[env]); const bookshelf = Bookshelf(knex as any); const { Model } = bookshelf; ...
Ryan Z's user avatar
  • 2,785
0 votes
1 answer
415 views

Successful query response won't display in Postman..?

I am working on a GET request, and I am having issues with getting my response to appear when using Postman. It prints to the console appropriately, but I would like to get it working in Postman if ...
Everest's user avatar
  • 97
1 vote
0 answers
335 views

Scheduling localhost serverless cron: The model could not be resolved in registry

I'm hosting an ExpressJS/NodeJS API on AWS Lambda with Serverless framework. The API uses Knex.js and Bookshelf.js ORM. I want to test scheduling a cron job locally. I'm using serverless-offline-...
user3871's user avatar
  • 12.7k
2 votes
1 answer
284 views

Bookshelf.js : Avoid fetch call after call to save (update)

We are using bookshelf.js with MySQL. We have a Table: Contact(id, name, email_Id, updated_Contact_At) bookshelf Query : new Contact({id: 1}).save( {name: 'Jhon Snow', email_Id: 'jhonsnow42@...
j10's user avatar
  • 2,251
0 votes
1 answer
258 views

How can I query in Bookshelf/Knex on a BelongsToMany join table?

I am running Bookshelf over MySQL in a Node application. I have a model called Document and another called Tag, which are joined through a belongsToMany relationship via a table called "...
Boris K's user avatar
  • 3,580
0 votes
2 answers
471 views

Bookshelf - get the id when a new record is created

I'm using bookshelf with mysql for my project and can't figure out how I can get the id when I'm creating a new record. Instead it just returns undefined. // model.js const User = bookshelf.model('...
ProV's user avatar
  • 261
0 votes
1 answer
1k views

How to get only one component from dymamiczone strapi bookshelf

I have this dynamiczone field in the model and i need this field for some endpoints so i made this "autoPopulate": false now I need to fetch only one component for e.g "extra-options.file-upload" but ...
Ginish Sharma's user avatar
0 votes
1 answer
248 views

bookshelf.js retrieve model name & assign it to instance via virtuals-plugin #beginner

I feel like this is a very stupid question, but as much as I try, I don't get any closer to solving it on my own; So, here we go: I install & setup the virtual plugin: bookshelf.plugin('...
Captain Husayn Penguin's user avatar
0 votes
1 answer
1k views

How to select columns from a relation

so I'm using Strapi and Bookshelf. The .query() is a normal bookshelf query. const result = await strapi.query('friendship').model .query({ where: { user1: 1 }, orWhere: { user2: ...
handy's user avatar
  • 1,036
0 votes
2 answers
191 views

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

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 ...
Captain Husayn Penguin's user avatar
2 votes
0 answers
2k views

include all includes in recursive relationship - strapi

I have a collection type component which includes a set of components. In a tree structure, They can have multiple components too. This include-depth can be any number. component : { components [] ...
Nilanka Manoj's user avatar
0 votes
1 answer
293 views

Inserting data in postgres with bookshelf ORM nodejs, getting error as relation does not exist

Inserting records, with bookshelf.. But getting bad luck on inserting, getting err as give below: let {mobile, email, name, active=1} = req.body let insert = { 'mobile_number': mobile, '...
Anupam Maurya's user avatar
0 votes
1 answer
112 views

Bookshelf JS Messing With Tablename

Introduction I'm trying to make a simple query on a table in mssql 2019 using the bookshelf.js and knex.js libraries. The table is part of a schema. Issue Description I get a sql error in my ...
Henry's user avatar
  • 7
0 votes
1 answer
961 views

How to hard delete by bookshelf when soft delete enable

Suppose, I want to delete temporarily so I can use soft delete by bookshelf, but in that case when I need to delete the permanently row of the table. So, How I can do that when soft delete is enabled ...
imrvasishtha's user avatar
1 vote
1 answer
184 views

How to combine and with or in bookshelfjs query builder?

I'm having problems with figuring out how to add multiple "and" queries that contain 'or' queries inside them The result i want in the end is something like this: select * from model where ...
Aurel Drejta's user avatar
0 votes
1 answer
491 views

Heroku fails in deploying node.js with bcrypt

after adding bookshelf-secure-password to my server heroku has been failing in deploying my server it keeps saying it can't install bcrypt. NPM_CONFIG_DISTURL=https://nodejs.org/download/release/ ...
Thor's user avatar
  • 83
0 votes
2 answers
438 views

How to check if email exist with bookshelf and mysql

I have been trying to check if email exist with bookshelfjs, but I always get empty response each time. If I try other fields it works perfectly. ( I prefer if this could work, is there something I ...
techstack's user avatar
  • 1,477
0 votes
0 answers
125 views

Bookshelf- how to order by relation

` new RevisionModel() .query('where', 'bbid', '=', req.params.bbid) .fetchPage({ limit: size, offset: from, withRelated: ['revision'] });` I want to sort the ...
prabalsingh's user avatar
0 votes
1 answer
3k views

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

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 ...
Roberto's user avatar
  • 424

1
2 3 4 5
12