I have two Mongoose queries and decided it would be best to use .lean() on them.
For the one that returns a single document, it seems to work fine:
let something:Something;
SomethingDocument.findOne({_id:theId}).lean().then( (res) => { something = res;});
The problem is when I try to use it with a query that returns multiple results:
let somethings:Something[];
SomethingDocument.find({color:'blue'}).lean().then( (res) => { somethings = res;});
The second call gives the error:
Type 'Object' is not assignable to type 'Something[]'.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
Property 'length' is missing in type 'Object'.
If I try to do a type conversion it just complains the the 'length' property is missing in type 'Object'.
How do I use lean when I expect an array of results?
...note that if I simply omit lean it all works.