public: 0 - удален
public: 1 - на модерации
public: 2 - одобрен
и т.д.
[{
_id: 1,
post: "text 1"
},{
_id: 2,
post: "text 2"}]
{
_id: 1,
name: "Name Collection"
posts: [
ObjectId("1"),
ObjectId("2")
]
}
function cleanUniqueDocument(request) {
return arr = [], elements = [], Promise.all(request.map( async (e) => {
return elements.map(function(i) { return i.tags }).indexOf(e.tags.join()) < 0 && elements.push({
href: e.url,
tags: e.tags.join()
}) || (e.canonical = elements.find(x => x.tags === e.tags.join()).href) && arr.push(e)
}))
.then(e => {
return arr || []
})
}