2019-09-21 21:53:55 +00:00
|
|
|
'use strict'
|
2019-09-22 05:05:30 +00:00
|
|
|
|
2019-09-21 21:53:55 +00:00
|
|
|
module.exports = {
|
2019-09-22 05:20:37 +00:00
|
|
|
getActor
|
2019-09-21 21:53:55 +00:00
|
|
|
}
|
|
|
|
|
2019-09-22 05:20:37 +00:00
|
|
|
const actorProj = { _id: 0, _meta: 0 }
|
|
|
|
const metaActorProj = { _id: 0 }
|
2019-09-21 21:53:55 +00:00
|
|
|
|
2019-09-22 05:05:30 +00:00
|
|
|
function getActor (id, db, includeMeta) {
|
2019-09-22 05:20:37 +00:00
|
|
|
return db.collection('objects')
|
|
|
|
.find({ id: id })
|
2019-09-21 21:53:55 +00:00
|
|
|
.limit(1)
|
|
|
|
// strict comparison as we don't want to return private keys on accident
|
|
|
|
.project(includeMeta === true ? metaActorProj : actorProj)
|
|
|
|
.next()
|
|
|
|
}
|