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

Mutators for Objection.js model

Is it possible to set mutators for the model? class MyModel extends Model { set email(email) { this.email = email ? email.toUppercase() : null; } } This code becomes a recursive call. How is the preferable way to handle it? I want to set…
1
vote
2 answers

How to build a JSON object in select query in Objection.js

I have a "location" jsonb type column in table "Ads". It stores values like these: {"lat": 33.742001, "lng": -117.823639, "zip": "92780", "city": "Tustin", "state": "CA"} How would I write a select query in Objection.js that returns the same…
demisx
  • 7,217
  • 4
  • 45
  • 43
1
vote
0 answers

Find entities by relation ids in objection.js

I have products and they related to categories categories: { relation: Model.ManyToManyRelation, modelClass: `${__dirname}/../../categories/models/category`, join: { from: 'products.id', through: { from:…
Vitalii
  • 157
  • 8
1
vote
1 answer

How to share models across different services/repos using postgres/knex.js/objection.js in node.js?

In standard micro-service architecture, each service is responsible for their own data with boundaries set. The only way to manipulate this data is through RESTful endpoints provided by the service. I have a unique case where I would like to have a…
PGT
  • 1,468
  • 20
  • 34
1
vote
1 answer

Insert/Select Mysql Spatial columns with ObjectionJS

I have a location table with a 'Point' type column in MySQL. I could define it using Knex and it worked correctly. knex.schema.createTable('locations',function(table){ table.increments('locid').primary(); table.string('address').notNullable(); …
Jagan Veeraraghavan
  • 363
  • 2
  • 4
  • 14
1
vote
1 answer

How to insert extra values in many-to-many table with Objection.js?

I have the following tables foo foo_bar bar --- ------- --- id foo_id id bar_id data num desc foo bar --- --- 1 (to be inserted) 2 I want to insert data into bar linking the inserted entry to…
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
1
vote
1 answer

How to work with data from a Promise

I'm new to JavaScript and am currently unable to wrap my head around Promise and how to retrieve data from them. I am using Express and Objection and have a route where I'd like to pull some data from the database und pass it to express'…
chilly
  • 304
  • 2
  • 13
1
vote
1 answer

Paging query with NodeJS and ObjectionJs

Hi I am relatively new to NodeJS and am using ObjectionJS as ORM. I want to do a migration script for my users table, in order to change some field of each row. I make something like this export default class UserMigration { constructor(firstId,…
MatayoshiMariano
  • 2,026
  • 19
  • 23
1
vote
2 answers

How parse data using join on Objection.js

I have two models: Place and User. I need to display only the list of places which have status = true and the status of the users which is true and the name of the place match the string enter by a user. class Place extends Model { static get…
Slim
  • 5,527
  • 13
  • 45
  • 81
1
vote
1 answer

_BAD_FIELD_ERROR: Unknown column 'table' in 'field list' with objection.js+mysql

I using mysql database and objection.js for handling my database actions.When I am trying to insert values, I am getting R_BAD_FIELD_ERROR: Unknown column 'table' in 'field list'. This is the code I am using for the insert data, Modelclass.query() …
Johncy Binoy
  • 169
  • 3
  • 13
0
votes
0 answers

Problem working with transactions using knex/objection

I have two databases that are used on an endpoint, this endpoint is developed with nodejs and serverless-framework, that is, it is a lambda function. I need to insert the information using transactions in both, in case an error occurs, the…
Fred
  • 182
  • 1
  • 22
0
votes
2 answers

Error inserting array into PostgreSQL column: Malformed array literal

I'm encountering an issue while trying to insert an array of strings into a PostgreSQL database column. The column is defined as follows: path TEXT[] NOT NULL here is the schema: path: { type: 'array', items: { type: 'string' }, notNull: true…
0
votes
0 answers

KnexTimeoutError when using knex.raw()

My node.js app uses knex as the ORM to connect to oracledb database. I am seeing an error with knex - KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call? at…
ashishpm
  • 408
  • 1
  • 6
  • 19
0
votes
0 answers

objection circular dependency and typescript definitions

There are two object in our datamodel that refer to each other, on database level each "client" owns some "scopes" (HasManyRelation). And each "scope" has many "clients" that are allowed access (ManyToManyRelation). The objection models would look a…
paul23
  • 8,799
  • 12
  • 66
  • 149
0
votes
0 answers

objection js - ValidationError: field must be object but the schema types is already set into object

I have a column augmentedTerms and result both are jsonb in my Postgres. This augmentedTerms contains an array of strings while result contains an array of objects. When I do patch, I got this error: ValidationError: augmentedTerms: must be object,…
Arman Ortega
  • 3,003
  • 1
  • 30
  • 28