Improve type::thing() function

When running type::thing() with a record id the function now returns the correct record. For example type::thing("test", test:id) now returns the record test:id.
This commit is contained in:
Tobie Morgan Hitchcock 2022-01-26 13:58:39 +00:00
parent 835018d5f4
commit 374644b9bd

View file

@ -102,8 +102,16 @@ pub fn table(_: &Runtime, mut args: Vec<Value>) -> Result<Value, Error> {
}
pub fn thing(_: &Runtime, mut args: Vec<Value>) -> Result<Value, Error> {
Ok(Value::Thing(Thing {
tb: args.remove(0).as_strand().value,
id: args.remove(0).as_strand().value,
}))
match args.remove(0) {
tb => match args.remove(0) {
Value::Thing(id) => Ok(Value::Thing(Thing {
tb: tb.as_strand().value,
id: id.id,
})),
id => Ok(Value::Thing(Thing {
tb: tb.as_strand().value,
id: id.as_strand().value,
})),
},
}
}