Hi,

Did you find a solution to this issue ?

Le lundi 9 juillet 2012 12:39:43 UTC+2, Phil Moorhouse a écrit :
>
> Is it possible to have both an $id field that uses MongoID and an 
> automatically managed auto-increment integer field (lets call it $key) in 
> the same document?
>
> I'd like to keep the MongoIds available internally but I also need 
> something to use in the URL for my REST API because the MongoIds are too 
> long and ugly. A simple auto-incrementing integer would suffice.
>
> I've tried this with:
>
>     /**
>      * @MongoDB\Id(strategy="AUTO")
>      * @JMSType("string")
>      * @JMSExclude
>      */
>     protected $id;
>
>     /**
>      * @MongoDB\Id(strategy="INCREMENT")
>      * @JMSType("integer")
>      */
>     protected $key;
>
> and 
>
>     /**
>      * @MongoDB\Int(strategy="INCREMENT")
>      * @JMSType("integer")
>      */
>     protected $key;
>
> but only the $id field ever gets created in MongoDB, the $key field 
> doesn't exist. I noticed that if I set the $id to INCREMENT, then Doctrine 
> creates another collection in MongoDB for implementing the side-counter 
> pattern described here: 
> http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field. 
> Is there any way to set up a field to use this strategy without overriding 
> the main ID?
>
>
> Cheers,
> Phil
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to