Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

References are not working #8

Open
RafaelKa opened this issue Mar 31, 2015 · 3 comments
Open

References are not working #8

RafaelKa opened this issue Mar 31, 2015 · 3 comments

Comments

@RafaelKa
Copy link

Hello Rens,

i tried to use selfreferenced Model.
persisting the model works fine, but i can not get the Models with findByParent(findByIdentifier('f49cb66745e5f0458ae108f2ff0ba163')).

{
   "_id": "f49cb66745e5f0458ae108f2ff0ba163",
   "_rev": "1-fe3deee4eec055d172cdb20bc651a9c7",
   "type": "THM.Products.Domain.Model.Product",
   "doctrine_metadata": {
       "indexed": true,
       "indexes": [
           "title",
           "parent"
       ],
       "associations": [
           "parent",
           "children"
       ]
   },
   "title": "Produkt 001",
   "properties": null,
   "parent": null,
   "children": [
   ]
}
{
   "_id": "f49cb66745e5f0458ae108f2ff0c1652",
   "_rev": "1-a4a68157c12c0f02991e688d9f4d866b",
   "type": "THM.Products.Domain.Model.Product",
   "doctrine_metadata": {
       "indexed": true,
       "indexes": [
           "title",
           "parent"
       ],
       "associations": [
           "parent",
           "children"
       ]
   },
   "title": "Kindprodukt001 von 001",
   "properties": null,
   "parent": "f49cb66745e5f0458ae108f2ff0ba163",
   "children": [
   ]
}

I need only Products without parent: also root products only.
To find out what is wrong i tried example from above.

Do you know, if some issues with self referencing on CouchDB ODM are available?

@radmiraal
Copy link
Owner

nope, I'm not aware of such issues, maybe it helps to do: findByParent('f49cb66745e5f0458ae108f2ff0ba163').

otherwise I wouldn't know, never used self referencing with this package

@RafaelKa
Copy link
Author

Hmmm,

it is!

How to find all Products where parent is null?

also findByParent(NULL); does not work.
is there some trick to do that?

@radmiraal
Copy link
Owner

when I need to do more advanced queries I always create my own views. You can do so by putting them in a folder like:

Migrations/CouchDB/DesignDocuments//views//

You have to put a map.js there, and can add a reduce.js. If you then run a ./flow migrate:designs it should add the design documents & views to couch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants