Skip to content

Can't use cosmoDB readonly key / Must use cosmoDB readwrite key  #1079

@vinaybedre

Description

@vinaybedre

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

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,

const dbResponse = await client.databases.createIfNotExists({
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 running createIfNotExists

Minimal reproduction of the problem with instructions

  1. Create any cosmodb in azure portal.
  2. Get the primary/secondary readonly keys to use in the library.
  3. Use the module AzureCosmosDbModule in a nestjs app with readonly key

What 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


Nest version: 10.3.7

 
For Tooling issues:
- Node version: v20.11.1  
- Platform: Mac 

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions