Closed nodefortytwo closed 10 years ago
Could you describe some of the use cases?
We have plans to work on a v2.0 and this sounds like a feature which we need to plan for. I'm not sure how easy it will be to patch without.
I read some of the use cases with regards to storing auto increment numbers or uuids. I'll look into how easy this would be.
yep those are valid use cases, you can also use complex types as ids, for example, in one application we have ids are that {"_id" : {account: "account_id", id:"id"}}
. there are obviously other ways of doing the same thing but its a nice feature of mongodb
Good to know. So with that the MongoId::id(array("account" => 123))
would return one or more than one? In you opinion?
Ahh I see what you are doing. Nesting multiple document types within one collection. But still give the scenario above how would you handle a partial query?
yeah thats interesting, i guess ::id should always return a single result, so a partial query wouldn't return any matches?
That was my thought too. Alright give me a few days.
@nodefortytwo so I'm considering a simple solution to patch this. Defining a new static variable like $customIdType
which by default is false. If set to true then we bypass any assumptions about MongoId
. Would this work for you? It would work like the static $useType = false;
A further solution would be to not assume ids are MongoId type unless specifically stated if the use of automatic converters and helpers were desired, but this will be a 2.0 feature.
that would work for me, in fact, in my own horrible ODM thats exactly how I handle it.
Thanks for taking the time to look at this. I love the rest of the ODM.
Sure thing. We use it in our production systems and want to see it succeed at being a light and robust solution. Feel free to get involved!
@nodefortytwo could you test this branch with your app to see if it works for you?
Apologies for the slow reply, This looks perfect, I carried out a few basic tests and everything worked perfectly. thanks guys
Glad to hear it!
Hi! as far as i can tell, the model _id has to be a MongoId. that isn't a requirement for mongodb and there are a few cases where specifying a different type of ID makes sense.
I would love to be able to use this ODM but that limitation prevents it ;(