03 Fields

from mongoengine import *
connect(db='Employee')

Create Document Class

class Employee(Document):
    emp_id = LongField(primary_key=True)
    first_name = StringField()
    last_name= StringField()
    email = EmailField()    
    birth_date=DateField()   
    salary = DecimalField()

Create Object

emp1 = Employee()
emp1.emp_id=1
emp1.first_name='Olee'
emp1.last_name= 'Ahmmed'
emp1.email='olee.techs@gmail.com'
emp1.birth_date='01/01/1994'
emp1.salary=10000
emp1.save()
emp2=Employee(emp_id = 2,first_name='Mim',last_name='Mahmuda',email='mimakther111122@gmail.com',birth_date='01/12/2006',salary=12000)
emp2.save()

Fields List

reference link

Last updated