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
0 answers

Best practice for where to put 2.8k lines of JSON/JS input for knex migration

I'm writing a knex/objection migration file that adds some non-user generated data to my database. For that, I have to input 2.8k lines of an array of objects: It just feels wrong to plop it straight into the migration file, so is there a…
Nathan Tew
  • 432
  • 1
  • 5
  • 21
0
votes
0 answers

Objectionjs withGraphJoined groupBy and orderBy occurence

I have a Nestjs app that runs on a SQL database using Objection.js as the ORM I have these tables: books id - integer name - string tags id - integer name - string And they both have a ManyToMany relationship through this table: book_tags id -…
Willower
  • 1,099
  • 8
  • 22
0
votes
0 answers

mySQL x Knexjs(objection js) - get data by date("yyyy-mm-dd") alone in where condition

I am sending 2 dates from ui for datefilter.i am using objection js query builder. I need to use WHERE condition with date format of 'yyyy-mm-dd'. The query building part: const data = await…
0
votes
0 answers

Typescript: Why Objection.js doesn't have Model field name code suggestion in select/column statement?

Using knex, when we do this: export const db = knex({}); db<{ id: string, name:string }>("").select(""); This select get code suggestion from the typescript vscode extension. But if we do this with objection: export class Budget extends Model { …
0
votes
1 answer

convert legacy objection.js code to objection.js 3

I have this legacy code below using objection.js and I need to convert this to objection.js 3. const result = await DeptClass.query() .select(['employeerClass.label', 'employeerClass.description', 'employeerClass.id']) …
Arman Ortega
  • 3,003
  • 1
  • 30
  • 28
0
votes
0 answers

objection how to correctly type relations for typescript?

Say I have a customer model which has multiple contact persons and a "first_name" field. For typing (say the first_name field) I would add first_name!: string|null; static get firstNameColumn(): string { return "first_name"; } However I have…
paul23
  • 8,799
  • 12
  • 66
  • 149
0
votes
0 answers

What is the correct type of migration file for defining schema?

In the objection getting started docs, it shows this function for defining a table schema: async function createSchema() { if (await knex.schema.hasTable('persons')) { return; } // Create database schema. You should use knex migration…
S S
  • 53
  • 4
0
votes
1 answer

How to apply filter on join table in many-to-many relation

I have many-to-many relationships between class and adventures. So, I have 3 tables named class, adventure and class_has_adventure. Class Table: Adventure Table: class_has_adventure Table: as you can see in the class_has_adventure table I have 2…
Mirza Umair
  • 349
  • 1
  • 16
0
votes
0 answers

Objection/Knex chaining where and orWhere doesn't work as expected, but orWhereExists does

I'm trying to filter for "GymGroups" which have "GymOutlets" that satisfy either of two conditions: either their name matches a substring, or their address matches a substring. I tried this, but it simply returns all entries from "GymGroups"…
Nathan Tew
  • 432
  • 1
  • 5
  • 21
0
votes
1 answer

Property 'id' does not exist on type 'User' ts(2339) when using generic method from an abstract class

TypeScript playground here. Let us define an interface: export interface User { id: string; } export class UserInstance implements User { id: string; constructor( id: string, ) { this.id = id; } } Then, suppose we have an…
0
votes
0 answers

ObjectionJS - How can I use withGraphJoined, using a comma separeted column of ids as source?

I have a mysql view with a field grouped and concatenated data insidelike this: | a | b | c | ---------------------------------------------- | 4 | lalala | 7,9,10 | | 9 | words | …
jon_eldiablo
  • 188
  • 2
  • 10
0
votes
0 answers

How to get related rows in MySQL with objection.js and knex

I have two tables: notes and tags, related by note_tags .createTable('notes', function (table) { table.increments('id').primary() table.string('title', 100).notNullable() table.string('content',…
0
votes
0 answers

How to add gates to Objection in NodeJS (AWS Lambda)?

I have an API developed with Serverless and serverless-offline which is deployed to AWS Lambda. Objection/Knex is used for DB, Firebase for authentication, and Middy to manage the requests. For the logged-in users, I'm trying to: Automatically add…
Mahesh Samudra
  • 1,039
  • 1
  • 11
  • 25
0
votes
0 answers

Objection.js - How to get records by inner joining table in Mysql

I have two tables, tbl_users and tbl_organisation_members. tbl_users has these columns. id name email tbl_organisation_members has these columns. id user_id status I want to convert the given query into Objection.js way. select om.id, u.name,…
Mohd Shahid
  • 1,538
  • 2
  • 33
  • 66
0
votes
0 answers

Not able to perform insert operation with transactions objection.js knex.js

js. I want to insert data by objection transaction. I started transaction with PrescriptionMetaData Model and related PrescriptionSymptom Model by relationMappings as followings. Eventually can't able to insert/patch with the following…
Harik
  • 13
  • 3