Replies: 3 comments 2 replies
-
Ping @Mr-Artemus |
Beta Was this translation helpful? Give feedback.
-
Hi there @barthofu !! Just to note you that I tried to run the bot with the MongoDB configuration, and I faced a lot of problems. I think is a little bit confuse this part of the documentation as you specify a tab for MongoDB, when in fact it is not possible to use it as is. First, you have to add this line in "database.ts" for MongoDB section:
I manage to make it work thanks to @Mr-Artemus commit #16. The main problem was that this required dependency was completely missing from your package.json:
So it was impossible to execute this code in getMigrator(em) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Migrator } = require('@mikro-orm/migrations-mongodb');
return this.config.getCachedService(Migrator, em);
} Beside of that, I think that the other main problem seems that in MongoDB (sorry, I'm very new to NoSQL) you are forced to use the "_id" field as Primary Key??? So you have to remove the @PrimaryKey decorator from every entity. The only one that I had to do it by myself was the Pastebin one, that I guess it didn't exist when @Mr-Artemus did his job: import { Entity, PrimaryKey, Property, EntityRepositoryType } from "@mikro-orm/core"
import { EntityRepository } from "@mikro-orm/sqlite"
import { CustomBaseEntity } from "./BaseEntity"
// ===========================================
// ================= Entity ==================
// ===========================================
@Entity({ customRepository: () => PastebinRepository })
export class Pastebin extends CustomBaseEntity {
[EntityRepositoryType]?: PastebinRepository
@Property()
editCode: string
@Property()
lifetime: number = -1
@Property()
createdAt: Date = new Date()
}
// ===========================================
// =========== Custom Repository =============
// ===========================================
export class PastebinRepository extends EntityRepository<Pastebin> {
} I tried to run the bot again but with 'better-sqlite' type in "database.ts", just to see if it was still compatible after the changes, but this error was thrown:
I don't know if this is something you can fix sometime in the future. Thank you for your great work @barthofu !! |
Beta Was this translation helpful? Give feedback.
-
Hi again @barthofu !! I really appreciate your work on this project and I hope to be able to contribute a fairer amount in the future. Thank you very much for your intention to credit me, but I really think I don't deserve it, as most of the work was done by @Mr-Artemus. I answer to your questions:
I'll get into your Discord after this message. Thank you very much! |
Beta Was this translation helpful? Give feedback.
-
The implementation of MongoDB in the template is something really important as it is used widely used (certainly not a good thing tho) by Discord bot developers.
As TSCord is using SQLite by default, it require some changes to switch it to mongodb, even if mikro-orm is abstracting a lot.
Theses changes has already been made in #16, but we don't really know yet how to apply these to the template. We've found two main solutions to this problem as far:
1. Documentation
Describe step by step the changes to make in the documentation.
2. Templates
Having 2 different templates: the one using sqlite, and the one using mongodb.
We would then have to choose the one we want during the installation with the
tscord init bot
command.+ Would be the open gate to other variants of the template (e.g: a one using Prisma, etc)
- This will be a huge change involving a lot of efforts as it would certainly implies a switch to a Monorepo architecture
We could also, in a first time, do the first solution as it is quite fast to write in the documentation, and then in the more long term implement the second solution.
Beta Was this translation helpful? Give feedback.
All reactions