Skip to content

Commit

Permalink
Move levelup to peer/dev dep and support 5.1.1
Browse files Browse the repository at this point in the history
Add promise example to README
Update simple example to use promises
  • Loading branch information
loune committed Nov 7, 2021
1 parent ae6113d commit 28664bc
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 213 deletions.
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
examples
test.js
.*/**/*
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [2.2.2] - 2021-11-07

### Changed

- Move `levelup` to peer dependency and support `^5.1.1`.

## [2.2.1] - 2021-02-14

### Changed
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ Arguments:

Please refer to the [AWS SDK docs to set up your API credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) before using.

### Using Promises

```js
(async () => {
// create DB
const db = levelup(s3leveldown('mybucket'));

// put items
await db.batch()
.put('name', 'Pikachu')
.put('dob', 'February 27, 1996')
.put('occupation', 'Pokemon')
.write();

// read items
await db.createReadStream()
.on('data', data => { console.log('data', `${data.key.toString()}=${data.value.toString()}`); })
.on('close', () => { console.log('done!') });
})();
```

### Using Callbacks

```js
const levelup = require('levelup');
const s3leveldown = require('s3leveldown');
Expand Down
25 changes: 15 additions & 10 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ if (!process.env.S3_TEST_BUCKET) {
return;
}

const db = levelup(s3leveldown(process.env.S3_TEST_BUCKET));
(async () => {
// create DB
const db = levelup(s3leveldown(process.env.S3_TEST_BUCKET));

db.batch()
.put('name', 'Pikachu')
.put('dob', 'February 27, 1996')
.put('occupation', 'Pokemon')
.write(function () {
db.readStream()
.on('data', console.log)
.on('close', function () { console.log('Pika pi!') })
});
// put items
await db.batch()
.put('name', 'Pikachu')
.put('dob', 'February 27, 1996')
.put('occupation', 'Pokemon')
.write();

// read items
await db.createReadStream()
.on('data', data => { console.log('data', `${data.key.toString()}=${data.value.toString()}`); })
.on('close', () => { console.log('done!') });
})();
8 changes: 4 additions & 4 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "pouchdb-example",
"name": "simple-example",
"version": "1.0.0",
"description": "Simple s3leveldown example",
"main": "index.js",
"author": "Loune",
"license": "MIT",
"private": true,
"dependencies": {
"aws-sdk": "^2.653.0",
"levelup": "^4.3.2",
"s3leveldown": "^2.1.0"
"aws-sdk": "^2.1023.0",
"levelup": "^5.1.1",
"s3leveldown": "^2.2.1"
},
"scripts": {
"start": "node index.js"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
"abstract-leveldown": "^6.3.0",
"debug": "^4.3.1",
"inherits": "^2.0.4",
"levelup": "^4.4.0",
"ltgt": "^2.2.1"
},
"peerDependencies": {
"aws-sdk": "^2.838.0",
"levelup": "^4.4.0"
"levelup": "^4.4.0 || ^5.1.1"
},
"devDependencies": {
"aws-sdk": "^2.838.0",
"jshint": "^2.12.0",
"levelup": "^5.1.1",
"tape": "^5.1.1"
}
}
Loading

0 comments on commit 28664bc

Please sign in to comment.