Meteor you're experiencing this issue 1.10.1Hello @msgfxeg ,
For .findOne() method this is expected behaviour, you got to check if .findOne() has results. Feel free to open new (or more preferably PR) ticket to update FileCursor documentation and .find() method documentation. .findOne() method is meant to work similarly to default Mongo's .findOne() method, as it meant to return null when record is not found.
For .find() there is no .link() method as it returns FilesCursor.
Hello @dr-dimitru,
Thanks for your reply it helped me a lot.
As I am using react with meteor. the problem was that react component updates twice, the first time before the mongo query succeeded! so I have to write it as follows:
useTracker(() => {
if (
Images.findOne({
_id: unit.images[0]
}) !== undefined
) {
return Images.findOne({
_id: unit.images[0]
}).link();
}
});
P.S: a bit of redundant code but it does not heart :)
@msgfxeg I'm glad this was fixed quickly
Please support this project with: