@jfln/marvin-db
Version:
biblioteca de objetos para normalizar o acesso a um banco mongo db
79 lines (71 loc) • 1.43 kB
text/typescript
import dotenv from 'dotenv'
dotenv.config()
import {Options} from '@mikro-orm/core'
import {MongoHighlighter} from '@mikro-orm/mongo-highlighter'
import {
Answer,
Audit,
Challenge,
Gif,
CustomEvent,
CustomEventParticipants,
CustomEventVotes,
DrawnEvent,
DrawnEventVotes,
HashtagEvent,
SettingsChannel,
SettingsConfession,
SettingsGeral,
SettingsMessages,
SettingsRules,
SettingsVent,
User,
UserBadges,
UserChallenge,
UserCoins,
UserLevel,
UserProfile,
UserProfileBackground,
UserPunishment,
UserTransaction,
} from './entities'
const entities = [
Answer,
Audit,
Challenge,
Gif,
CustomEvent,
CustomEventParticipants,
CustomEventVotes,
DrawnEvent,
DrawnEventVotes,
HashtagEvent,
SettingsChannel,
SettingsConfession,
SettingsGeral,
SettingsMessages,
SettingsRules,
SettingsVent,
User,
UserBadges,
UserChallenge,
UserCoins,
UserLevel,
UserProfile,
UserProfileBackground,
UserPunishment,
UserTransaction,
]
const mongoUrl = () => {
return `mongodb+srv://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@${process.env.MONGO_HOST}/${process.env.MONGO_DB_NAME}${process.env.MONGO_EXTRAS_CONFIG}`
}
// console.log(mongoUrl())
const options: Options = {
type: 'mongo',
clientUrl: mongoUrl(),
dbName: 'MarvinDBTest',
highlighter: new MongoHighlighter(),
debug: false,
entities: entities,
}
export default options