Support nested labels in 'persistent-mongoDB'#82
Support nested labels in 'persistent-mongoDB'#82superbobry wants to merge 1 commit intoyesodweb:masterfrom superbobry:feature/nested-mongodb-labels
Conversation
|
Thanks for getting involved in improving MongoDB. From your example I can't tell what the point of this is: you would be better off just using a single field called "name". Can you give a use case that better demonstrates the purpose? |
|
Well, in my case, the database "schema" was already fixed by another tool we use, so I couldn't just go with "name". In general, I don't think this pattern is very common, but anyway, here's an example from MongoDB manual: item : {
"title" : <title> ,
"price" : <price> ,
"sku" : <sku> ,
"features" : {
"optical zoom" : <value> ,
...
}
} |
|
yeah so technically speaking one only needs nested arrays, but a nested hash can be useful for organization. The way one is supposed to achieve nesting before this patch is through data types: share [mkPersist sqlSettings] [persist|
Self
name String Eq
Person sql=person
self Self
age Int
deriving Show
|]The only problem I see here is that Persistent does not really support embedded queries. It would be great to run a query like this: insert $ Person (Self "Garry") 3
person <- selectFirst [PersonSelfName == "Bob"] [] |
|
You can do this query now: insert $ Person (Self "Garry") 3
person <- selectFirst [PersonSelf ==. (Self "Bob")] []Note this is a query about every value of the Self object, still no way to query on an embedded field. My understanding of your patch is that it is for inserts and doesn't add query capabilities. |
|
Well, some of the document we have to work with are deeply nested, and having 3-4 intermediate objects probably won't work well. Anyway, this is clearly and exception, so I think it would be better to keep the patch local. |
Hello, the current version of persistent-mongoDB doesn't support nested labels, so for example the following code doesn't work as expected, treating
self.nameas a flat label:I've updated
insertFieldsandmapFromDocto support nested labels, so nowself.nameis saved as:{self: {name: "Garry"}}