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

Objection variable number of columns in a model

Well say I have a model from a database schema. However this schema itself might be variable, apart from the id and key columns the number of columns might change/grow over time, I do not know the name of the columns beforehand. (Yes I realize this…
paul23
  • 8,799
  • 12
  • 66
  • 149
0
votes
1 answer

Objection js sub query when using Eager methods

Does any body knows why ObjectionJs makes a sub query when using Eager methods? ModelA.query().withGraphJoined('tableB') The sql query is select "tableA"."id" as "id" "tableA" left join (select "tableB". from "tableB") as "tableB" on "tableB"."id"…
0
votes
1 answer

Using joinRelated for multiple relation filtering

I have a collection, a product and a collection_product join table. If I'm trying to filter products based on collection ids, I do the following: Product.query() .modify((builder) => { if (collectionIds?.length) { builder …
Norbert
  • 2,741
  • 8
  • 56
  • 111
0
votes
1 answer

whereIn not working with raw in objection js

I am using Objection.js ORM of Node.js. I want to use whereIn with raw Here is what I am trying - var bookingData = await DoctorBookingsModel .query() .select('b.id as booking_id','b.appointment_date') .from('doctor_bookings as…
amM
  • 509
  • 2
  • 14
  • 33
0
votes
2 answers

How to add external model to ObjectionJS?

We are using ObjectionJS in our app (Express + NodeJs + Mysql) for a log time but now I want to refactor the code in order to make easier to read and faster to implement, so one of my first approach is to make Objection Model import an external…
Philip Enc
  • 1,072
  • 15
  • 21
0
votes
1 answer

Objection.js - insert data based on "where" condition

I want to insert a data into my database based on "where" condition, but I couldn't success. Objection.js : const User = require('../../database/models/user'); router.route('/register') .get((req,res,next)=>{ …
Oxibital
  • 135
  • 1
  • 2
  • 10
0
votes
2 answers

Objection.js: Can all where clauses be enclosed in parentheses after they have been added?

Code example // Creates an Objection query. // I have no control over the creation of the query. I can only modify the query after it has been created. // Example: "select `todos`.* from `todos` where `text` = ?" const objectionQuery =…
Mike
  • 613
  • 1
  • 10
  • 20
0
votes
1 answer

How can I get the rows of a table in the same order as it is in my database, using ObjectionJS relationMapping?

I have a table called pathway, pathway_courses, and courses. The idea is, each pathway has certain number of courses. pathway_courses is the join table joining pathway table from id to courses table. Basically, pathway (id) -->…
0
votes
1 answer

Objection Relation Mapping with transformed values

Let's say I have two tables : People: name : place ----- : ------ ben : park phil : office Food: food_place : vegetable ----------- : --------- ben@park : carrots phil@office : potatoes I'd like to create a Relation Mapping, I tried: …
Hollyol
  • 827
  • 1
  • 13
  • 25
0
votes
0 answers

How can i insert into a table that has many relational with other table

I using knex with objection js and i want to insert to roomType table with roomImage table at the same because table roomType has many roomImage This my database .createTable(tableName.roomImage, (table) => { …
0
votes
0 answers

Very slow performance in objections.js with relation models

I build graphql server based on the node.js, objection.js, objection-graphql, knex. I have about 200 models in the app and it worked good before I connect relations. Each model has in avarage 3 relation model, exist many loops, by this cause I use…
befreeforlife
  • 481
  • 2
  • 7
  • 21
0
votes
1 answer

Use virtualAttributes with jsonSchema in objection

I would like to have an additional column with a modified value from another column: Now I have next code like this but it doesn't work: const { Model } = require("objection"); class TestModel extends Model { static get tableName() { …
befreeforlife
  • 481
  • 2
  • 7
  • 21
0
votes
1 answer

Joining table on value included in joint table as extra value

I've faced a problem I cant neither solve nor find solution in documentation and issues. In short description, I'm building an ecommerce solution, where I have following models: Product, Variant, Attribute, AttributeDictionary Shortly, whenever user…
0
votes
0 answers

How to count number of times the primary key of a row is referenced in a specific table with Objection.js

(Using PostgreSQL) So, I have these (User and Vote) Objection.js models: const { Model } = require('objection'); class User extends Model { static get tableName() { return 'users'; } static get relationMappings() { return { …
0
votes
0 answers

How to ignore/exclude the migration and seeding of certain tables

Currently i have to seed all the files even though there is change in a single file csv. Is there a way that we can seed only a specific file while data seeded in the previous/existing files remains as it is in DB. Also i wanted to know if we can…