Replies: 2 comments
-
Your problem is that you are not defining the array as a JSON property, this makes your test pass: @Property({ type: 'json' })
myEmbedded?: EntityEmbeddable[] = []; Note that this way you will get POJOs in there, they wont be instances of the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Love it! Works like a charm. Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm not sure if I'm doing it correctly. I want to save a infinite hierarchy. To do this, I define an entity with an attribute that refers to itself and as an array.
It is saved correctly (I followed this discussion: #3145 ). But something is wrong with the query.
Attached is the complete test. embedded.test.ts.txt
The problem:
Mongo-Entity on the Database:
At the moment I solved the problem with jsonpath:
But this is not sexy and not typed.
I saw in #3145 the support for define it will probably never going be supported. But it works! Except querying it.
I also know, there would be other solutions to save infinite hierarchy e.g. saving a parent-key on each entity. But the advantage of storing it as object in mongodb is the quick and easy access of parts of the hierarchy with a simple query.
Does this statement still apply? And also for find? 🥺
Regards
What driver are you using?
@mikro-orm/mongodb
MikroORM version
6.2.5
Node.js version
v20.12.2
Operating system
Ubuntu 22.04.4 LTS
Beta Was this translation helpful? Give feedback.
All reactions