Questions tagged [objection.js]

An Object Relational Mapper (ORM) for Node.js

Formerly known as moron.js, objection.js is an Promise based ORM built on top of knex.js focusing on the loading and storing of javascript objects into relational databases, specifically the ones supported by knex.js.

It does not currently incorporate a query builder leaving that for knex.js.

Website: https://vincit.github.io/objection.js

Github repo: https://github.com/Vincit/objection.js/

284 questions
0
votes
1 answer

Getting error when using objection JS to create query: NJS-012: encountered invalid bind data type in parameter 2

I have been spending hours trying to debug this error. I am using Node, Joi and Oracledb. When I attempted to make a POST request to insert my data from the payload of the request to my table, it gives me the error: NJS-012: encountered invalid bind…
Quan Khuc
  • 39
  • 1
  • 1
  • 6
0
votes
1 answer

Is there a good way to implement Objection/Sequelize on an existing database?

I have an existing database with 10 or so tables and thousands of rows. I’m tiring of SQL and would like to add an ORM — probably either Objection or Sequelize. Is there a good way to implement either ORM on an existing database?
0
votes
1 answer

Is there a way to access ObjectionsJs model property

I'm building a node js app with Objection + knex. I was wondering if that is possible to access the declared property in the Model when doing the request ? That way, TS is everywhere. In the doc, every time the Model property are inside string. Here…
TPCRomain
  • 51
  • 2
0
votes
2 answers

How to do some constraint checking during knex/objectionjs raw query

I am doing some raw query binding in objectionjs and my code is as follows: const item = await cart.$relatedQuery('items').insert(req.body) .onConflict(['cartId', 'productId']) .merge({ amount:…
skylark
  • 11
  • 3
0
votes
1 answer

FeathersJS cannot create user with ObjectionJS and SQLite

I am experimenting with FeathersJS. To do so, I generated a new feathers app $ feathers g app with the following configuration: ? Do you want to use JavaScript or TypeScript? JavaScript ? Project name test ? Description ? What folder should the…
tobi-or-not
  • 566
  • 4
  • 13
0
votes
1 answer

How to Run Postgresql procedures with Knex in Node js

I am trying to call a stored procedure saved in the public schema using: const schema = await knex.raw("call create_schema(?, 'col1', 'col2', 'col3', 'col4', 'col5', 'col6')", schema_name); The procedure is to create a schema for a new…
Fhuad Balogun
  • 47
  • 2
  • 8
0
votes
1 answer

how to create a knex migration for creating a column depending on other columns?

I have a Node.js project and I'm using knex.js as a query builder. I have model called cuboid: import { Id, RelationMappings } from 'objection'; import { Bag } from './Bag'; import Base from './Base'; export class Cuboid extends Base { id!: Id; …
0
votes
1 answer

How to setup mutli-tenancy using row level security on Postgres with knex

I am architecting a database where I expected to have 1,000s of tenants where some data will be shared between tenants. I am currently planning on using Postgres with row level security for tenant isolation. I am also using knex and Objection.js to…
Sam Duvall
  • 265
  • 2
  • 13
0
votes
0 answers

Automatically update a column on insert - ObjectionJS

I want to automatically update the CreatedDateTime column whenever I want to insert or update column. But my problem is some tables have no CreatedDateTime column. My code looks like this: $beforeInsert(context) { this.CreatedDateTime = new…
Ryan Garde
  • 742
  • 1
  • 7
  • 20
0
votes
0 answers

Why objection instance method did not work

I have setup the Objection model for Company, if I use static method to query database it is OK. (I already have Model.knex(knex) before to setup everything.) const companyInfo = await Company.query().findById(1) But if I create company instance…
0
votes
0 answers

Knex / ObjectionJs whereJsonSupersetOf with object containing an array

I use knex and objection.js with a postgresQL database. I updated knex from version 0.19.5 to 1.0.3 and part of one of my query stopped working. One of my table has a 'metadata' column, which is jsonb. The metadata object can contain a keyword…
Marie Pelletier
  • 417
  • 2
  • 4
  • 15
0
votes
2 answers

How to do a relatedQuery (many2many) with feathers-objection

Regarding to this post: https://stackoverflow.com/a/69903276/1547821 it shows an approach with less boilerplate, to prevent a users query output (GET) to only the user who is logged in. But how to do this, to get i.e. all members of the related…
0
votes
1 answer

Unable to assign types because Postgresql wrapped results in table name

I created a table in PostgreSQL using knex: await knex.schema .withSchema('public') .createTable('question', (table) => { table.increments('id').primary(); table.text('title').notNullable().index(); …
ytan11
  • 908
  • 8
  • 18
0
votes
1 answer

How to Optimize Subquery in Objection JS?

I want to optimise my subquery. From the mysql doc i found. SELECT * FROM t1 WHERE t1.column1 IN ( SELECT column1 FROM t2 ORDER BY column1 ); SELECT * FROM t1 WHERE t1.column1 IN ( SELECT…
0
votes
1 answer

Is Paging efficient in Objectionjs orm?

On every paged query, I see 2 query one is query with limit and offset. One is count. Does this have any performance issues on every request when there are multiple joins?