mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
added rethink promise API
This commit is contained in:
@@ -7,9 +7,9 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) {
|
||||
var testDb = r.db('test')
|
||||
testDb.tableCreate('users').run(conn, function(err, stuff) {
|
||||
var users = testDb.table('users')
|
||||
|
||||
|
||||
users.insert({name: "bob"}).run(conn, function() {})
|
||||
|
||||
|
||||
users.filter(function(doc?) {
|
||||
return doc("henry").eq("bob")
|
||||
})
|
||||
@@ -19,6 +19,24 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) {
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
// use promises instead of callbacks
|
||||
r.connect({host:"localhost", port: 28015}).then(function(conn) {
|
||||
console.log("HI", conn)
|
||||
var testDb = r.db('test')
|
||||
testDb.tableCreate('users').run(conn).then(function(stuff) {
|
||||
var users = testDb.table('users')
|
||||
|
||||
users.insert({name: "bob"}).run(conn, function() {})
|
||||
|
||||
users.filter(function(doc?) {
|
||||
return doc("henry").eq("bob")
|
||||
})
|
||||
.between("james", "beth")
|
||||
.limit(4)
|
||||
.run(conn);
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user