Expand index trait to also include key type
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
@@ -77,11 +77,10 @@ fn main() {
|
||||
|
||||
// Load all active users using the IsActive field index
|
||||
// TODO: expand Index type so it defines the type of the key
|
||||
let key = true.to_string();
|
||||
let active_users = db
|
||||
.collection::<User>()
|
||||
.expect("can open user collection")
|
||||
.get::<IsActive>(&key)
|
||||
.get::<IsActive>(&true)
|
||||
.expect("can load stored users");
|
||||
// We should have 2 active users
|
||||
assert_eq!(active_users.len(), 2);
|
||||
@@ -96,15 +95,14 @@ fn main() {
|
||||
let active_users = db
|
||||
.collection::<User>()
|
||||
.expect("can open user collection")
|
||||
.get::<IsActive>(&key)
|
||||
.get::<IsActive>(&true)
|
||||
.expect("can load stored users");
|
||||
assert_eq!(active_users.len(), 1);
|
||||
// And verify we still have 2 inactive users
|
||||
let key = false.to_string();
|
||||
let inactive_users = db
|
||||
.collection::<User>()
|
||||
.expect("can open user collection")
|
||||
.get::<IsActive>(&key)
|
||||
.get::<IsActive>(&false)
|
||||
.expect("can load stored users");
|
||||
assert_eq!(inactive_users.len(), 2);
|
||||
|
||||
|
Reference in New Issue
Block a user