![](/img/trans.png)
[英]Mikro ORM unique decorator is not being enforced when
使用這個實體: 當嘗試插入重復項時(基於 case 和 csgItem 的組合,mikroORM 允許我這樣做。如何使@unique裝飾器與關系一起工作? ...
[英]Mikro ORM unique decorator is not being enforced when
使用這個實體: 當嘗試插入重復項時(基於 case 和 csgItem 的組合,mikroORM 允許我這樣做。如何使@unique裝飾器與關系一起工作? ...
[英]MikroORM: No Update Event Fired When Adding an Entity to a Collection
在 MikroORM 中,我有兩個實體,我們稱它們為實體 A 和實體 B,它們建立了一對多關系。 實體 A 有一個實體 B 實例的集合。 我正在使用事件訂閱者來監聽實體 A 的更新。 當我將新的實體 B 添加到實體 A 的集合中時,不會為實體 A 觸發更新事件。但是,當我從集合中刪除實體 B 時,會 ...
[英]Nested populate not working for mikro-orm
我將mikro-orm與nest.js一起使用,我有用戶、角色和權限實體。 我需要通過 ID 選擇用戶及其角色和數據庫中的權限。 我正在使用以下代碼來選擇具有所有內容的用戶: 我需要結果類似於以下代碼示例,但未選擇permissions : 這是我的實體和模式的樣子: 數據庫中生成了roles_p ...
[英]MikroORM - validate the current SQL db schema as with hbm2ddl.auto=validate
MikroORM 是否可以驗證當前的 SQL 數據庫模式 (Postgres)? 我想在應用程序啟動時運行此驗證,因為 Hibernate 使用hbm2ddl.auto=validate ...
[英]Use MikroORM migrations with NestJs
我在使用命令mikro-orm migration:create時遇到問題。 控制台向我顯示Error: MikroORM config file not found in ['./dist/mikro-orm.config.js', './mikro-orm.config.js'] 。 我的 ap ...
[英]How use seeding options in MikroOrm with nestJs?
我在 nestJs 中使用 MikroOrm,並在package.json中添加了以下腳本 這些是配置 在編寫npm run orm seeder:run --class=ClassNameSeeder時,我需要指定一個特定的種子文件,如文檔所述,但出現以下錯誤 我還嘗試在package.json ...
[英]How to run `union` SQL command in MikroORM
還詢問了GitHub 。 我想在 MikroORM 中使用union 。 似乎沒有內置方式(如qb.union() ,因此我認為我需要運行原始 SQL 命令(通過qb.raw() )或使用 Knex 構建命令。 例如,我想根據某些條件從表中獲取一些行,但是無論如何,至少要返回具有最大 ID 的兩行。 ...
[英]How to mock wrap().assign() of MikroORM when using with NestJS, the objective is unit testing a update method
我有這樣的方法 與官方提供的示例類似,該示例也對服務進行了單元測試,但沒有對更新方法進行測試。 我想為上述方法實施單元測試,但是當我嘗試時出現以下錯誤 我應該怎么做才能解決這個問題? ...
[英]Can't create migrations using MikroORM and NestJS
由於配置文件出現意外錯誤,無法創建遷移或任何其他 MikroORM CLI 命令。 這是我的 package.json 上使用的 MikroORM 和 NestJS 的當前版本 根據官方文檔,MikroORM CLI 在package.json中配置為使用ts-node 這是我的mikro-orm- ...
[英]How to get the iterated item in findAll()
我正在使用 Mikro-ORM 和 NEST.JS。 我有用戶、游戲和消息。 我想找到所有用戶和他們的游戲,並只填充用戶發送的那些消息。 在 find(id) function 中這很容易完成,因為在參數中我有用戶的 id,所以我可以將消息的用戶與用戶進行比較。 用戶.service.js:asyn ...
[英]Trying to create mikroConfig to MikroORM with typescript and i got this error message
我正在研究 TS 並構建一個微配置文件,例如: 當我嘗試編譯控制台給我這個: src/mikro-orm.config.ts:6:7 - error TS2322: Type 'Options<IDatabaseDriver<Connection>> | Configurat ...
[英]MIKRO-ORM: What is the best way to handle the count of votes on a post?
我有 2 個實體,如下所示。 我的問題是返回與給定帖子相關聯的總票數的最簡單/最有效的方法是什么? PostVote有一個可以是Up或Down的枚舉vote 。 我正在考慮使用序列化程序,但您仍然會返回所有PostVote行,只是為了得到一個計數。 我應該只做單獨的 em.count() 查詢還 ...
[英]Mikro EntityManager in NestJS bull processor not working
我想在任務處理器中進行一些查詢: promise 永遠不會在@Process() function 中解決。 謝謝。 ...
[英]How can I use a contructor on an Entity that has properties with @ManyToOne decorator without passing instances of other entities and only their ids?
如何在具有@ManyToOne裝飾器屬性且它們的類型來自另一個實體但僅具有主鍵的實體上使用構造函數。 例如: 我想要的實體的實例應該類似於 findOne 返回的實例而不填充任何內容。 ...
[英]MikroORM: How to use 'insert_id' for subsequent persists?
如何從持久化中獲取 insert_id(或重復鍵錯誤上的現有 id)? 我想在刷新前的以下持久性中使用它。 在我看來,即使 EntityManager 還沒有 id,它仍然可以填充它並在刷新期間將其用作它,但我認為我的想法在這里有缺陷,我是 MikroORM 的新手。 從我在文檔中看到的內容來看, ...
[英]Cannot access reference from inverse side of a 1:1 relationship
我有以下兩個實體(當然簡化了問題): 用戶.ts Class.ts 我可以從用戶端訪問 class 參考很好,但我不能從 Class 端訪問類主管(用戶參考)。 我也嘗試填充,但沒有運氣。 如何從反面訪問用戶? 這不可能嗎? 這是一個示例代碼: ...
[英]Error: Must use import to load ES Module - MikroOrm and Typescript
我正在嘗試初始化一個 mikrorm 設置來處理我的 postgres DB,但由於 ESM 編譯錯誤,我無法運行我的 run-dev 腳本: 我深入研究了必須更改的 tsconfig 內容或松散導入可能導致的問題,但遺憾的是我沒有發現任何指向它的文件(index.ts、mikro-orm.con ...
[英]Mikro-ORM: How can I return first item in collection?
我有 2 個像下面這樣的實體,但我只想返回一個stats object。 Mikro-ORM 將其作為數組返回。 有沒有辦法告訴 Mikro-ORM 將數組中的第一個元素作為 object 返回? 最終結果類似於deck.stats.stats_property 。 而不是deck.stats[ ...
[英]Cannot determine GraphQL output type for 'books' of 'Bible' class. Is the value, decorated with a proper decorator or is it a proper output value?
作為背景,我在 MongoDB 上使用 MikroOrm 和 type-graphql 我創建了我的 class 並在屬性“books”中將其設置為 class Book 的數組。 這是 class 書。 根據 type-graphql 文檔,@Field(() => [Book]) 發生錯 ...
[英]MikroOrm: Get list of schemas
如何檢索 mikro-orm.config.js 數據庫連接的所有模式的列表? 我試過了 但“結果”總是未定義 ...