2019-09-22 05:05:30 +00:00
|
|
|
'use strict'
|
2019-09-15 02:49:33 +00:00
|
|
|
|
2019-09-22 05:05:30 +00:00
|
|
|
module.exports = async function dbSetup (db, domain, dummyUser) {
|
2019-09-22 05:20:37 +00:00
|
|
|
// inbox
|
|
|
|
await db.collection('streams').createIndex({
|
|
|
|
'_meta._target': 1,
|
|
|
|
_id: -1
|
|
|
|
}, {
|
|
|
|
name: 'inbox'
|
|
|
|
})
|
|
|
|
// followers
|
|
|
|
await db.collection('streams').createIndex({
|
|
|
|
'_meta._target': 1
|
|
|
|
}, {
|
|
|
|
partialFilterExpression: { type: 'Follow' },
|
|
|
|
name: 'followers'
|
|
|
|
})
|
|
|
|
// outbox
|
|
|
|
await db.collection('streams').createIndex({
|
|
|
|
actor: 1,
|
|
|
|
_id: -1
|
|
|
|
})
|
|
|
|
// object lookup
|
|
|
|
await db.collection('objects').createIndex({
|
|
|
|
id: 1
|
|
|
|
})
|
|
|
|
if (dummyUser) {
|
|
|
|
return db.collection('objects').findOneAndReplace(
|
|
|
|
{ preferredUsername: 'dummy' },
|
|
|
|
dummyUser,
|
|
|
|
{
|
|
|
|
upsert: true,
|
|
|
|
returnOriginal: false
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2019-09-22 05:05:30 +00:00
|
|
|
}
|