Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
310 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
seq = require 'seq' | ||
assert = require 'assert' | ||
db = require('../src/index').getClient({ api: 'protobuf', debug: false }) | ||
|
||
bucket = 'riakjs_protobuf' | ||
print = (message) -> console.log "=> " + message | ||
|
||
seq([1,2,3,4]) | ||
|
||
.flatten(fully = false) | ||
|
||
.parEach (number) -> | ||
print "saving doc number #{number}" | ||
db.save bucket, "#{number}", { test: 'yes', number: number }, @ | ||
|
||
.seq -> | ||
print 'retrieving that doc' | ||
db.get bucket, '1', @ | ||
|
||
.seq (contents) -> | ||
print 'document matches what saved' | ||
assert.deepEqual(contents, { test: 'yes', number: 1}) | ||
@() | ||
|
||
.seq -> | ||
print 'gimme all buckets' | ||
db.buckets @ | ||
|
||
.seq (buckets) -> | ||
print "our bucket #{bucket} is in the list of buckets" | ||
assert.ok(bucket in buckets) | ||
@() | ||
|
||
.seq -> | ||
print 'now lets map/reduce the hell out of it' | ||
db.add(bucket).map((v) -> v = Riak.mapValuesJson(v)[0]; if 1 < v.number < 4 then [v] else []).run(@) | ||
|
||
.seq (results) -> | ||
print "this stuff should be in by now" | ||
assert.deepEqual results, [[{ test: 'yes', number: 2 }, { test: 'yes', number: 3 }]] | ||
@() | ||
|
||
.seq -> | ||
print 'now gimme all keys' | ||
db.keys bucket, @ | ||
|
||
.seq (keys) -> | ||
print 'see if our doc is there...' | ||
assert.ok('1' in keys) | ||
@(null, keys) | ||
|
||
.flatten() | ||
|
||
.seqEach (key) -> | ||
print 'cleaning up key '+ key | ||
db.remove bucket, key, @ | ||
|
||
.seq -> | ||
db.buckets @ | ||
|
||
.seq (buckets) -> | ||
print 'bucket shouldnt exist anymore' | ||
assert.ok(bucket not in buckets) | ||
@() | ||
|
||
.seq -> | ||
print "[result] 's all good" | ||
db.end() | ||
|
||
.catch (err) -> | ||
print 'omg we fucked up' | ||
console.dir err | ||
db.end() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.