0
var oldMatches = Meteor.users.find(userId, {
    fields: {
        _id: false,
        matches: true
    }
}).fetch()

This returns an object with an empty matches array, as it should. How would I access this array to find the length of it?

Thanks.

K K
  • 17,794
  • 4
  • 30
  • 39
Nathan
  • 470
  • 2
  • 5
  • 15

1 Answers1

0

You would find the length of the array with

oldMatches.length

So:

if(oldMatches.length) {
    // is not empty
} else {
    // is empty
}

N.B. length only works on a returned array from fetch, not a Meteor cursor

Ian Jones
  • 1,369
  • 1
  • 10
  • 15
  • oldMatches.length gives me the length of 1, because it contains 1 array. I need the length of the array. I've tried oldMatches.matches.length, which is what I assumed would work, but it's not. – Nathan Mar 30 '15 at 14:14