rubberguppe/db/setup.js

36 lines
887 B
JavaScript
Raw Normal View History

2019-09-21 21:20:14 +00:00
const pub = require('../pub')
2019-09-15 02:49:33 +00:00
module.exports = async function dbSetup (db, domain) {
// 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
})
2019-09-21 21:20:14 +00:00
const dummyUser = await pub.actor.createLocalActor('dummy', 'Person')
await db.collection('objects').findOneAndReplace(
{preferredUsername: 'dummy'},
2019-09-15 02:49:33 +00:00
dummyUser,
{
upsert: true,
returnOriginal: false,
}
)
}