some cleanups and fixed #161

This commit is contained in:
Theodor Diaconu 2017-06-30 18:13:42 +03:00
parent ec487ee614
commit 63bd6b3e6d
5 changed files with 81 additions and 59 deletions

View file

@ -61,7 +61,5 @@ function constructMetadataSchema(field, isMany, metadataSchema) {
schemaDefinition[field + suffix + '.' + key] = value;
});
console.log(schemaDefinition);
return schemaDefinition;
}

View file

@ -116,11 +116,10 @@ function cloneMetaChildren(node, parentResults) {
}
export function assembleMetadata(node, parentResults) {
// assembling metadata is depth first
node.collectionNodes.forEach(collectionNode => {
const linkName = collectionNode.linkName;
_.each(parentResults, result => {
assembleMetadata(collectionNode, result[linkName])
assembleMetadata(collectionNode, result[node.linkName])
});
});
@ -131,7 +130,8 @@ export function assembleMetadata(node, parentResults) {
_.each(childResult, object => {
const storage = object[node.linkStorageField];
return storeMetadata(object, parentResult, storage, true);
storeMetadata(object, parentResult, storage, true);
});
})
} else {

View file

@ -8,26 +8,27 @@ import Posts from './posts/collection';
import Tags from './tags/collection';
import Groups from './groups/collection';
Authors.remove({});
Comments.remove({});
Posts.remove({});
Tags.remove({});
Groups.remove({});
Meteor.startup(() => {
Authors.remove({});
Comments.remove({});
Posts.remove({});
Tags.remove({});
Groups.remove({});
const AUTHORS = 6;
const POST_PER_USER = 6;
const COMMENTS_PER_POST = 6;
const TAGS = ['JavaScript', 'Meteor', 'React', 'Other'];
const GROUPS = ['JavaScript', 'Meteor', 'React', 'Other'];
const COMMENT_TEXT_SAMPLES = [
const AUTHORS = 6;
const POST_PER_USER = 6;
const COMMENTS_PER_POST = 6;
const TAGS = ['JavaScript', 'Meteor', 'React', 'Other'];
const GROUPS = ['JavaScript', 'Meteor', 'React', 'Other'];
const COMMENT_TEXT_SAMPLES = [
'Good', 'Bad', 'Neutral'
];
];
console.log('[testing] Loading test fixtures ...');
console.log('[testing] Loading test fixtures ...');
let tags = TAGS.map(name => Tags.insert({name}));
let groups = GROUPS.map(name => Groups.insert({name}));
let authors = _.range(AUTHORS).map(idx => {
let tags = TAGS.map(name => Tags.insert({name}));
let groups = GROUPS.map(name => Groups.insert({name}));
let authors = _.range(AUTHORS).map(idx => {
return Authors.insert({
name: 'Author - ' + idx,
profile: {
@ -35,9 +36,9 @@ let authors = _.range(AUTHORS).map(idx => {
lastName: 'Last Name - ' + idx
}
});
});
});
_.each(authors, (author) => {
_.each(authors, (author) => {
const authorPostLink = Authors.getLink(author, 'posts');
const authorGroupLink = Authors.getLink(author, 'groups');
@ -67,6 +68,7 @@ _.each(authors, (author) => {
Comments.getLink(comment, 'author').set(_.sample(authors));
})
})
});
});
console.log('[ok] fixtures have been loaded.');
console.log('[ok] fixtures have been loaded.');
})

View file

@ -221,6 +221,28 @@ describe('Hypernova', function () {
})
});
it('Should fetch direct One Meta links with $metadata that are under a nesting level', function () {
let authors = createQuery({
authors: {
$options: { limit: 1 },
posts: {
$options: { limit: 1 },
group: {
name: 1
}
}
}
}).fetch();
let data = authors[0];
_.each(data.posts, post => {
assert.isObject(post.group.$metadata);
assert.isDefined(post.group.$metadata.random);
});
});
it('Should fetch Inversed One & Many Meta links with $metadata', function () {
let data = createQuery({
groups: {

View file

@ -1,6 +1,6 @@
Package.describe({
name: 'cultofcoders:grapher',
version: '1.2.8',
version: '1.2.8_1',
// Brief, one-line summary of the package.
summary: 'Grapher makes linking collections easily. And fetching data as a graph.',
// URL to the Git repository containing the source code for this package.