Fixes #309 - weird removal due to link handling

This commit is contained in:
Theodor Diaconu 2018-10-25 09:09:24 +03:00
parent 8e94ce89cf
commit b55be7045e
2 changed files with 14 additions and 2 deletions

View file

@ -84,6 +84,17 @@ export default class Link {
return result;
}
/**
* This is just like fetch() but forces to get an array even if it's single result
*
* @param {*} filters
* @param {*} options
* @param {...any} others
*/
fetchAsArray(filters, options, ...others) {
return this.find(filters, options, ...others).fetch()
}
/**
* When we are dealing with multiple type relationships, $in would require an array. If the field value is null, it will fail
* We use clean to make it an empty array by default.

View file

@ -7,6 +7,7 @@ import smartArguments from './linkTypes/lib/smartArguments';
import dot from 'dot-object';
import { check } from 'meteor/check';
import { _ } from 'meteor/underscore';
import { access } from 'fs';
export default class Linker {
/**
@ -298,9 +299,9 @@ export default class Linker {
return;
}
let accessor = this.createLink(doc);
const accessor = this.createLink(doc);
_.each(accessor.fetch(), linkedObj => {
_.each(accessor.fetchAsArray(), linkedObj => {
const { relatedLinker } = this.linkConfig;
// We do this check, to avoid self-referencing hell when defining virtual links
// Virtual links if not found "compile-time", we will try again to reprocess them on Meteor.startup