The `oci-database` package provides a Node.js client for interacting with the Oracle Cloud Infrastructure (OCI) Database service. It allows developers to programmatically manage database resources such as Autonomous Databases, DB Systems, and various database operations within OCI. This package is part of the larger OCI TypeScript SDK, offering type-safe access to OCI services. Currently at version 2.130.0, the OCI SDK typically follows a frequent release cadence, often aligning with OCI service updates, leading to multiple minor or patch releases per month. Key differentiators include first-party support from Oracle, comprehensive TypeScript type definitions, and integration with OCI's native authentication mechanisms, providing a robust and official way to automate database management tasks in the OCI ecosystem.
npm install oci-databaseVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the `DatabaseClient` using API key authentication from a configuration file and lists all databases within a specified compartment in OCI.
Review OCI IAM documentation for required policies (e.g., `read databases` for listing) and ensure they are assigned to the calling user/group.
Refer to the OCI SDK documentation for 'Configuring Credentials'. Ensure `~/.oci/config` is correctly set up with the private key path, fingerprint, and other details. Use environment variables or instance principals where appropriate.
Implement a loop that repeatedly calls the list operation, passing the `opcNextPage` token from the previous response in the `page` parameter of the subsequent request, until `opcNextPage` is null.
Ensure the region configured in your `ConfigFileAuthenticationDetailsProvider` or explicitly set on the client matches the region where your OCI Database resources are located. Example: `new DatabaseClient({ authenticationDetailsProvider: provider, region: common.Region.US_ASHBURN_1 });`Verify `~/.oci/config` entries, API key fingerprint, and `private_key_file` path. Ensure your user OCID is correct. For instance principals, check associated dynamic groups and policy permissions.
Review OCI IAM policies in the OCI Console. Add the required `allow` statements for the user's group or dynamic group to `manage` or `read` the specific resource type (e.g., `databases`) in the target compartment.
Ensure you are using ES module imports (`import { DatabaseClient } from 'oci-database';`) in an environment configured for ESM, or if using CommonJS, verify the export structure of the package. It's usually a named export.Double-check the OCID of the resource you are targeting. Verify that the OCI client's configured region matches the region where the resource resides. OCI OCIDs are globally unique but resources are region-bound.