Update entities to have more options

This commit is contained in:
Henrik Hüttemann 2023-06-05 15:33:32 +02:00
parent b02db837cb
commit 870128dd6e
No known key found for this signature in database
GPG Key ID: 9F7BD10E0A8A111E

View File

@ -20,13 +20,33 @@ const AppDataSource = new DataSource({
}) })
const enum Entities { const enum Entities {
Users = 'users.json', Users = 'users',
Rooms = 'rocketchat_room.json', Rooms = 'rooms',
Messages = 'rocketchat_message.json', Messages = 'messages',
}
type EntityConfig = {
filename: string
mappingType: number
}
const entities: { [key in Entities]: EntityConfig } = {
users: {
filename: 'users.json',
mappingType: 0,
},
rooms: {
filename: 'rocketchat_room.json',
mappingType: 1,
},
messages: {
filename: 'rocketchat_message.json',
mappingType: 2,
},
} }
async function loadRcExport(entity: Entities) { async function loadRcExport(entity: Entities) {
const rl = new lineByLine(`./inputs/${entity}`) const rl = new lineByLine(`./inputs/${entities[entity].filename}`)
let line: false | Buffer let line: false | Buffer
while ((line = rl.next())) { while ((line = rl.next())) {