Size: a a a

TypeORM - Русскоязычное сообщество

2020 February 28

VA

Victor Assis in TypeORM - Русскоязычное сообщество
ILshat Khamitov
Please write what you want in sql language, without typeorm
": "Pampulha - MG",
         "numberOfMouths": null,
         "shakingModel": null,
         "productType": "A",
         "registrationType": "V",
         "tankCapacity": null,
         "active": true,
         "createdAt": "2020-02-27T15:35:32.931Z",
         "updatedAt": "2020-02-27T15:35:32.931Z",
         "idPlaque": 1
       },
       {
         "plaque": "LSJ0023",
         "description": "Arraial dos Lucas",
         "numberOfMouths": null,
         "shakingModel": null,
         "productType": "A",
         "registrationType": "T",
         "tankCapacity": null,
         "active": true,
         "createdAt": "2020-02-27T15:45:00.042Z",
         "updatedAt": "2020-02-27T15:45:00.042Z",
         "idPlaque": 2
       }
     ]
   }

And if I pass skip 0 and take 2 return the both registers normally. Ok.. But I have filters and searchs in this. I can search by the plaque by example.. I tried to do with 'create query builder' all works less than pagination.. The code of typeorm is:

const compositions = await createQueryBuilder(Composition, 'composition')
                   .leftJoinAndSelect('composition.plaques', 'plaques')
                   .where(`composition.status <> 1 AND ${filterAndSearchOptions.where} ORDER BY ${filterAndSearchOptions.orderBy} ${filterAndSearchOptions.direction}${filterAndSearchOptions.pagination}`,
                       filterAndSearchOptions.params)
                   .getMany();

the variable filterAndSearchOptions do the controll of search and filters.. but when I pass skip 0 and take 1 then return only one register with only one plaque.. Because it is a many to many relation..

it returns:
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
{
     "status": 2,
     "createdAt": "2020-02-27T15:46:00.349Z",
     "updatedAt": "2020-02-27T15:46:00.349Z",
     "idComposition": 1,
     "plaques": [
       {
         "plaque": "HGW4865",
         "description": "Pampulha - MG",
         "numberOfMouths": null,
         "shakingModel": null,
         "productType": "A",
         "registrationType": "V",
         "tankCapacity": null,
         "active": true,
         "createdAt": "2020-02-27T15:35:32.931Z",
         "updatedAt": "2020-02-27T15:35:32.931Z",
         "idPlaque": 1
       }
     ]
   }
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
and if i pass skip 1 and take 1 it returns :
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
{
     "status": 2,
     "createdAt": "2020-02-27T15:46:00.349Z",
     "updatedAt": "2020-02-27T15:46:00.349Z",
     "idComposition": 1,
     "plaques": [
     {
         "plaque": "LSJ0023",
         "description": "Arraial dos Lucas",
         "numberOfMouths": null,
         "shakingModel": null,
         "productType": "A",
         "registrationType": "T",
         "tankCapacity": null,
         "active": true,
         "createdAt": "2020-02-27T15:45:00.042Z",
         "updatedAt": "2020-02-27T15:45:00.042Z",
         "idPlaque": 2
       }
     ]
   }
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
The same register but only the plaque different
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
I wanted to know a way to do a pagination with the second way.. :x Sorry by the text..
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
I have no idea how to do this in sql or typeorm.. Im losted.. kk
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
Here are one example:
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
this get one register and skip none
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
Notice that it return the same register with 2 categories..
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
I wanted that returns two products
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
And this show the records in database:
https://example-pagination.herokuapp.com/products
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
And this is the code for these endpoins:

let where = '1=1';

   if(q.pageSize && q.skip){
     where = 1=1 LIMIT ${q.pageSize} OFFSET ${q.skip};
   }

   const ps = await createQueryBuilder(Product, 'product')
   .leftJoinAndSelect('product.categories', 'categories')
   .where(where)
   .getMany();
   return ps;
источник

VA

Victor Assis in TypeORM - Русскоязычное сообщество
Its a simple example to explain my question.. And if u know how I can do a respect of this..
источник
2020 March 02

n

neurosys in TypeORM - Русскоязычное сообщество
Either do/investigate one of the following:

a subquery instead of join. Grouping, or two separate selects and enrich in application memory.
источник

KA

Kylych Asankulov in TypeORM - Русскоязычное сообщество
всем привет ребята! что не так
QueryFailedError: invalid input syntax for type uuid: "{"id":"30fe9951-6a55-4921-a9c8-b2a4f3779744"}"
источник

YZ

Yaroslav Zhymkov in TypeORM - Русскоязычное сообщество
Kylych Asankulov
всем привет ребята! что не так
QueryFailedError: invalid input syntax for type uuid: "{"id":"30fe9951-6a55-4921-a9c8-b2a4f3779744"}"
Переведите ошибку
источник

KA

Kylych Asankulov in TypeORM - Русскоязычное сообщество
Короче говоря у меня айдишник типа uuid. Когда пытаюсь
findOne(
{where: {id: is} }
)

то ругается что не может сделать запрос
источник