Undefined value from a collection field

Hi! I’m new in Meteor and I’m developing a little application who shows the stored values of an element in the collection in a chart. When I wanna obtain the field values of the collection element, I do: var val = Device.find({‘name’: name}).values, and val have the value undefined.
Is it not the way to obtain the field like this?

Sorry for my inexperience and thanks in advance.

If you’re doing what I think you’re doing, you could try

Device.find({'name': name}).fetch()[0].values

But I’d need to see more code to be sure. Also, if this is on the client you will need to be sure the data is available before doing this.

I suggest you try …

console.log(" **** Found :: ", Device.find({'name': name}) );

then examine your browser console to get a better understanding of what the returned object contains.

Really fine! Like this is the true way. This code is in the client side but I suscribed to the collection. Now I can work with the values. Thanks!

1 Like