Properties have types. In neomodel, all the basic types are available:
- String
- Integer
- Float
- Boolean
- Date, DateTime
- UniqueID
Apart from that, there are other extra types that exist as well, as follows:
- JSON
- Email (a string with extra checks for its format)
- Point (the Neo4j spatial type)
Each of these properties is created with some optional parameters to define; for instance, whether they are required or not.
For our purposes, let's create a User model with the following properties:
- login (String): Required and a primary key
- password (String): Required
- email (Email): Optional
- birth_date (Date): Optional
The User model should look like this:
class User(StructuredNode):
login = StringProperty(required=True, primary=True)
password = StringProperty(required=True)
email = EmailProperty()
birth_date = DateProperty()
Now that our model exists, we can use it to create and retrieve nodes, without writing any Cypher queries.