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

create table from model in objection.js

i want to use an ORM for oracle in nodejs. in my searches i see many ORM but I narrow it down to typeorm and objection. I take an example of objection from github but tables created from migration not from models. How can I create table from a…
riouha
  • 1
  • 2
0
votes
1 answer

Objection.js not proper return

i am not getting proper the return after insertgraph in objection.js i am getting the result like : [ User { name: 'Santosh Devi', city: 'Suratgarh', number: '9898987458', userroles: UserRoles { role_id: 2, user_id: 37 }, id:…
Kapil
  • 61
  • 1
  • 8
0
votes
1 answer

How do you add USE INDEX (indexname) to ObjectionJS query

I have a select statement: const myObject = await MyObject .query() .eager('foo') .eager('foo.bar') .omit(['some_big_data']) // Skip the giant field to improve performance/memory .where('when_created', '>',…
JimmyDix
  • 81
  • 4
0
votes
1 answer

Return Unaffected Rows in Postgres

I have a Postgres DB and using ObjectionJS as my ORM. I have the following ObjectionJS code to patch two columns of a user_system table. public static async DeleteSystem(systemId: number, context: Context): Promise { const system =…
Siya Mzam
  • 4,655
  • 1
  • 26
  • 44
0
votes
1 answer

How to joined 2 tables and output fields from the adjacent table?

everybody, could you please tell me I use the objection.js (ORM) library for knex.js joined Users and Roles tables, everything is great. I use it: const users = await User.query().eager().roles') I'm getting it: {"id":1, "email": "ann@mail.com",…
0
votes
1 answer

RequestError: Connection lost - read ECONNRESET

I am new to mssql getting error while i am deploying it into my dev environment but at local it works fine only for specific query it doesn't work Here is my code return Order.query() .joinEager('[shipments.shipmentQuantities.lineItem,…
Kiwi Rupela
  • 2,238
  • 5
  • 24
  • 44
0
votes
2 answers

Is there anyway to read a value in a file and sync with the presence value in database?

hi i have a table that store all configuration setting, at the same time, i also have one hardcoded config file. but, i have problem when user, which is non developer want to access some config value, and the config value is not presence in database…
Naju Mat Isa
  • 55
  • 1
  • 7
0
votes
1 answer

Order records by eager results count and implement pagination based on that in Objection.js?

I have these tables: Users Skills Has_skills (user_id, skill_id) I'm passing an array of skill IDs to the function which should fetch users who have at least one of those skills. The query should be efficient in a way so it fetches a number of…
krcky
  • 81
  • 2
  • 11
0
votes
1 answer

How to always filter on a column by default in Knex / Postgres?

When we're deleting data, often instead of deleting a DB row we instead set a date_deleted column (for non-privacy-sensitive data) so that the data is accessible later for auditing if necessary. How can we use Objection, Knex, or Postgres to…
Freewalker
  • 6,329
  • 4
  • 51
  • 70
0
votes
1 answer

Trying to structure a SQL or Knex query for social posts from groups where user is a member

I have 4 tables queried using a combination of raw sql, knex and objection.js queries. Users and Groups are associated by Memberships and Posts which belong to Groups Primary/Foreign Keys Users: id, has_many Groups via Memberships Groups: id,…
user2799827
  • 1,077
  • 3
  • 18
  • 54
0
votes
2 answers

How to query jsonb (postgtresql) in feathers/objections ORM?

I read the docs from: https://github.com/feathersjs-ecosystem/feathers-objection Still can not query a jsonb column. My table contains: id, some_other_fields, segmentation: jsonb Segmentation columns has values like: {"type": "WT", "group": "D",…
SharpBCD
  • 547
  • 1
  • 7
  • 25
0
votes
2 answers

Knex, Objection.js, How to sort by number of associations

I have an Express API using Postgres via Knex and Objection. I want to set up a Model method or scope that returns an array of Parent model instances in order of number of associated Children. I have looked through the Knex an Objection docs I have…
user2799827
  • 1,077
  • 3
  • 18
  • 54
0
votes
0 answers

How to define a manytomany relationship on the same table in objectionjs?

I have an article table, where an article can cite multiple articles. Each article can also have a single author. Article model : class Article extends DefaultModel { static get tableName() { return "articles"; } static get…
Zee
  • 824
  • 11
  • 25
0
votes
0 answers

Keep business logic saving related models in Data Model using $beforeInsert or not?

Let's assume i have two Models in Objection Books and Chapters . What i want to achieve is before inserting Book to DB to save 1 default entry on Chapters table and return the creates chapter.id and save it to Books. What is the best approach ?…
0
votes
1 answer

How to setup another username in database?

I'am a newbie frontend trainee, and I have a task to configure my project on node-typescript-koa-rest. I tried to do my best to configure it, but it has an error. First of all, I get this project,…