Expand index trait to also include key type

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2025-04-23 15:09:54 +02:00
parent 276cf3c8d8
commit 1343e61e0f
5 changed files with 75 additions and 58 deletions

View File

@@ -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);