Skip to content

Commit

Permalink
fix: updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
seekayel committed Jun 22, 2023
1 parent 7197cc5 commit 8e9e69a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,41 @@ Together with the Cyclic.sh DynamoDB indexing strategy and data model, the SDK s

> Credentials are required only for connecting to the database from local and expire after one hour, don't add them to an environment configuration.
3. Set the database name as an environment variable before requiring the SDK - this can be added to environment configurations.
3. Set the database name as an environment variable before requiring the SDK - this can be added to environment configurations.

```js
process.env.CYCLIC_DB = 'your-url-subdomainCyclicDB'
import db from '@cyclic.sh/dynamodb'
```
```js
process.env.CYCLIC_DB = 'your-url-subdomainCyclicDB'
const db = require('@cyclic.sh/dynamodb')
```
----------

# Example
## ESM or CJS

You can use either esm or cjs imports. Any of the below examples can be altered with the import type of you choice.

### ESM
```js
// example.mjs
import CyclicDB from '@cyclic.sh/dynamodb'
const db = CyclicDB('your-table-name')
```

### CommonJS

```js
// example.cjs
const CyclicDB = require('@cyclic.sh/dynamodb')
const db = CyclicDB('your-table-name')
```

# Examples

```js
// example.js
// example.cjs
const CyclicDB = require('@cyclic.sh/dynamodb')
const db = CyclicDB('your-table-name')
Expand Down Expand Up @@ -113,7 +137,7 @@ The TTL setting passes through to the [DynamoDB TTL](https://docs.aws.amazon.com
## Example

```js
// example.js
// example.cjs
const CyclicDB = require('@cyclic.sh/dynamodb')
const db = CyclicDB('your-table-name')
Expand Down
2 changes: 1 addition & 1 deletion test/instantiate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ process.env.AWS_REGION = process.env.AWS_REGION || "us-east-2";
// import { CyclicDb } from "../src";
import db_import from "../src";

describe("require('CyclicDb')", () => {
describe("import db from ../src", () => {
test("can be used as an object relying on env vars ", async () => {
const db = db_import;

Expand Down

0 comments on commit 8e9e69a

Please sign in to comment.