-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapter factory? #94
Comments
I'm not sure how to solve it per se but basically it would be nice if the adapter could accept a string, a class or a factory function which gives you the instance rather than relying on you to construct the adapter. For example something like this may work: const { mongo } = services // already configured and connected
await migrationManager.configure({
adapter: undefined,
adapterFactory: () => new MongoAdapter(mongo)
}) |
Hi, that |
Except when run programmatically in another application. I really need to control the construction specifically in that case. I have a workaround fortunately: const { services } = context
const { mongo } = services // already configured and connected
class DynamicAdapter extends Adapter<TContext> {
private migrations: Collection<IMigration>
public async connect(): Promise<TContext> {
this.migrations = mongo.getCollection<IMigration>('migrations') // references mongo instance in higher scope
return await Promise.resolve(context)
}
// etc...
}
await migrationManager.configure({
adapter: DynamicAdapter
}) I need to do this because I need more than just a database connection for migrations, I need a full context of my application, connections to multiple services, etc. For example, if you update a particular database record you may need to also push a message into a stream or queue or call a 3rd party api. So anyway, I have a workaround but its inellegant, I think it would be very helpful to make it possible to accept adapter instances for programmatic uses rather than require a constructor specifically. |
I am trying to use east programmatically, I already have a mongo client and connection, but I can't figure out how to just provide that connection to east already.
The text was updated successfully, but these errors were encountered: