File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ import datetime
2
+ from typing import Optional
3
+
4
+ from pydantic import EmailStr
5
+
6
+ from aredis_om import Field , HashModel , Migrator
7
+
8
+
9
+ class Customer (HashModel ):
10
+ first_name : str
11
+ last_name : str = Field (index = True )
12
+ email : EmailStr
13
+ join_date : datetime .date
14
+ age : int = Field (index = True )
15
+ bio : Optional [str ]
16
+
17
+
18
+ andrew = Customer (
19
+ first_name = "Andrew" ,
20
+ last_name = "Brookins" ,
21
+
22
+ join_date = datetime .date .today (),
23
+ age = 38 ,
24
+ )
25
+
26
+ await Migrator ().run ()
27
+
28
+ await Customer .find ().delete ()
29
+
30
+ andy = await andrew .save ()
31
+
32
+ customers = await Customer .find (Customer .last_name == "Brookins" ).all ()
33
+ assert len (customers ) == 1
34
+
35
+ await Migrator ().run ()
36
+
37
+ customers_count = await Customer .find ().count ()
38
+ assert customers_count == 1
39
+
40
+ brookins_count = await Customer .find (Customer .last_name == "Brookins" ).count ()
41
+ assert brookins_count == 1
You can’t perform that action at this time.
0 commit comments