Update entities to have more options
This commit is contained in:
parent
b02db837cb
commit
870128dd6e
28
src/app.ts
28
src/app.ts
@ -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())) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user