Open vinaybedre opened 2 months ago
I think you're right, there needs to be an option to avoid the createIfNotExists
in both places in the codebase.
Temporarily you can monkey patch the Databases
or Containers
class to do nothing with the createIfNotExists
method.
For example:
Databases.prototype.createIfNotExists = async function () {
// Your logic here
};
Containers.prototype.createIfNotExists = async function () {
// Your logic here
};
Thank you for submitting this feature request @vinaybedre! Is this something you feel comfortable implementing? I can provide support if you need 😀
Yes I am able to create a version where there is an option called createIfNotExists
which has a default value of true.
@jeremylcarter please feel free to submit a PR.
I'm submitting a...
Current behavior
The library usage requires us to have read-write cosmodb API key, where as it could be used for a readonly purpose with a readonly key. In this line, https://github.com/nestjs/azure-database/blob/78511e49b8af060bccbadd55a5eae0f58a84542d/lib/cosmos-db/cosmos-db-core.module.ts#L26 we try to run a createIfNotExists which needs a readwrite key.
Expected behavior
The library must be able to use with both readonly and readwrite keys. We could enhance the module options with a
isReadOnly
property, which skips runningcreateIfNotExists
Minimal reproduction of the problem with instructions
AzureCosmosDbModule
in a nestjs app with readonly keyWhat is the motivation / use case for changing the behavior?
Flexibility. There could be business usecases, where some of the micro services should only have readonly access to the database, instead of readwrite. Currently this flexibility is missing in the library.
Environment