Using autoincrement for mongodb with php doctrime odm

SImple trick very nice because this strategy for the columns it is really good!
 Using autoincrement for mongodb with php doctrime odm

http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/basic-mapping.html#identifiers

Create a document:


/** Document */
class mydoc
{
    /** @Id(strategy="INCREMENT", type="int") */
    private $id;
 
}

You can configure custom ID strategies if you don’t want to use the default MongoId. The available strategies are:
  • AUTO - Uses the native generated MongoId.
  • ALNUM - Generates an alpha-numeric string (based on an incrementing value).
  • CUSTOM - Defers generation to a AbstractIdGenerator implementation specified in the class option.
  • INCREMENT - Uses another collection to auto increment an integer identifier.
  • UUID - Generates a UUID identifier.
  • NONE - Do not generate any identifier. ID must be manually set.
SO simple as that.
  • INCREMENT - Uses another collection to auto increment an integer identifier.

0 pensamientos:

Post a Comment

feedback!