Skip to content

Instantly share code, notes, and snippets.

@itsdevcoffee
Created April 19, 2016 07:26
Show Gist options
  • Select an option

  • Save itsdevcoffee/5972b388cac5caa0b530b87f6f9ca88d to your computer and use it in GitHub Desktop.

Select an option

Save itsdevcoffee/5972b388cac5caa0b530b87f6f9ca88d to your computer and use it in GitHub Desktop.
import { Person } from '/lib/collections';
import { Groups } from '/lib/collections';
import { Realtor } from '/lib/collections';
import { Relocation } from '/lib/collections';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export default function () {
Meteor.methods({
'person.map.model'() {
const { userId } = this;
let groups = Groups.find({userId}, {fields: {memeberEmail: 1}}).fetch();
let relocation = Relocation.find({userId}, {fields: {email: 1, phoneNumber: 1}}).fetch();
let realtor = Realtor.find({userId}, {fields: {clientName: 1, clentCell: 1, workPhone: 1}}).fetch();
let matchedArray = [];
// Records where phoneNumber === cell or work
relocation.forEach((reloc) => {
let matchedRealtor = Realtor.find({clentCell: reloc.phoneNumber}).fetch()
if(matchedRealtor.length > 0) {
matchedArray.push(matchedRealtor);
}
});
console.log(matchedArray.length);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment