Link Search Menu Expand Document

IDField

Table of contents

  1. Example Usage
  2. Allowed Attributes
    1. Default
    2. Required

IDField is special field which is used to specify custom id for documents. If no id specify then id will be generated automatically.

Example Usage

class User(Mode):
    user_id = IDField()



u = User()
u.user_id = "custom_doc_id"
u.save()
# After save id will be saved in `user_id`
print(self.user_id)  # custom_doc_id

Allowed Attributes

The following attributes supported by ID Field.

  1. default
  2. required
  • Default

    Default value for field. This is base attribute that is available in all fields. Read More

  • Required

    Set True if value is required for the field. This is base attribute that is available in all fields. Read More