cher-db
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -180,5 +180,8 @@ | ||
moderation: socialContentUtils.parseModeration(opts.moderation), | ||
source: opts.source | ||
}); | ||
if (opts.source) { | ||
query = query.where({ source: opts.source }); | ||
} | ||
if (opts.after) { | ||
@@ -203,9 +206,28 @@ query = query.where(`social_content.fetched_at`, '>', opts.after); | ||
let allContent = yield query.fetchAll(); | ||
let tasks = allContent | ||
.map((item) => { | ||
return co(function*() { | ||
return yield SocialContent | ||
const i = yield SocialContent | ||
.where({ id: item.get('id') }) | ||
.fetch({ withRelated: ['tags'] }); | ||
.fetchAll({ withRelated: ['tags'] }); | ||
return i.filter((model) => { | ||
// If we're querying for content with specifie tags, then grab | ||
// the related tags for each item and see if it has the target | ||
// tag attached to it | ||
if (opts.tags) { | ||
return opts.tags.some((targetTag) => { | ||
return model.related('tags') | ||
.some((relatedTag) => { | ||
return ( | ||
relatedTag.get('key') === targetTag.key && | ||
relatedTag.get('value') === targetTag.value | ||
); | ||
}); | ||
}); | ||
} else { | ||
return true; | ||
} | ||
}); | ||
}); | ||
@@ -215,3 +237,6 @@ }); | ||
return co(function*() { | ||
return yield tasks; | ||
const ret = yield tasks; | ||
return ret.reduce((prev, next) => { | ||
return prev.concat(next); | ||
},[]); | ||
}); | ||
@@ -221,3 +246,2 @@ | ||
} | ||
}); | ||
@@ -224,0 +248,0 @@ |
{ | ||
"name": "cher-db", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Data layer for Cher", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ # cher-db | ||
const SocialContent = models.get('SocialContent') | ||
db.destroy() // destros the db connection | ||
db.destroy() // destroys the db connection | ||
}) | ||
@@ -16,0 +16,0 @@ ``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24539
666
0