Comparing version 1.16.2 to 2.0.0
// Generated by CoffeeScript 1.7.0 | ||
var ArrayResult, AtomFeed, Cursor, EventEmitter, Feed, IterableResult, Promise, ar, aropt, err, mkErr, protoResponseType, setImmediate, util, varar, | ||
var ArrayResult, AtomFeed, Cursor, EventEmitter, Feed, IterableResult, OrderByLimitFeed, Promise, UnionedFeed, ar, aropt, err, mkErr, protoResponseType, setImmediate, util, varar, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
@@ -143,8 +143,2 @@ __slice = [].slice, | ||
break; | ||
case protoResponseType.SUCCESS_FEED: | ||
this._handleRow(); | ||
break; | ||
case protoResponseType.SUCCESS_ATOM_FEED: | ||
this._handleRow(); | ||
break; | ||
case protoResponseType.SUCCESS_SEQUENCE: | ||
@@ -225,4 +219,8 @@ if (response.r.length === 0) { | ||
return resolve(); | ||
} else { | ||
} else if (_this._closeCb == null) { | ||
_this._closeCb = function(err) { | ||
while (_this._cbQueue.length > 0) { | ||
_this._cbQueue.shift(); | ||
} | ||
_this._outstandingRequests = 0; | ||
if (err) { | ||
@@ -234,8 +232,7 @@ return reject(err); | ||
}; | ||
if (_this._outstandingRequests > 0) { | ||
return _this._closeAsap = true; | ||
} else { | ||
_this._outstandingRequests += 1; | ||
return _this._conn._endQuery(_this._token); | ||
} | ||
_this._closeAsap = true; | ||
_this._outstandingRequests += 1; | ||
return _this._conn._endQuery(_this._token); | ||
} else { | ||
return _this.emit('error', new err.RqlDriverError("This shouldn't happen")); | ||
} | ||
@@ -464,3 +461,3 @@ }; | ||
function Feed() { | ||
this._type = protoResponseType.SUCCESS_FEED; | ||
this._type = protoResponseType.SUCCESS_PARTIAL; | ||
Feed.__super__.constructor.apply(this, arguments); | ||
@@ -485,2 +482,26 @@ } | ||
UnionedFeed = (function(_super) { | ||
__extends(UnionedFeed, _super); | ||
function UnionedFeed() { | ||
this._type = protoResponseType.SUCCESS_PARTIAL; | ||
UnionedFeed.__super__.constructor.apply(this, arguments); | ||
} | ||
UnionedFeed.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("`hasNext` is not available for feeds."); | ||
}; | ||
UnionedFeed.prototype.toArray = function() { | ||
throw new err.RqlDriverError("`toArray` is not available for feeds."); | ||
}; | ||
UnionedFeed.prototype.toString = ar(function() { | ||
return "[object UnionedFeed]"; | ||
}); | ||
return UnionedFeed; | ||
})(IterableResult); | ||
AtomFeed = (function(_super) { | ||
@@ -490,3 +511,3 @@ __extends(AtomFeed, _super); | ||
function AtomFeed() { | ||
this._type = protoResponseType.SUCCESS_ATOM_FEED; | ||
this._type = protoResponseType.SUCCESS_PARTIAL; | ||
AtomFeed.__super__.constructor.apply(this, arguments); | ||
@@ -511,2 +532,26 @@ } | ||
OrderByLimitFeed = (function(_super) { | ||
__extends(OrderByLimitFeed, _super); | ||
function OrderByLimitFeed() { | ||
this._type = protoResponseType.SUCCESS_PARTIAL; | ||
OrderByLimitFeed.__super__.constructor.apply(this, arguments); | ||
} | ||
OrderByLimitFeed.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("`hasNext` is not available for feeds."); | ||
}; | ||
OrderByLimitFeed.prototype.toArray = function() { | ||
throw new err.RqlDriverError("`toArray` is not available for feeds."); | ||
}; | ||
OrderByLimitFeed.prototype.toString = ar(function() { | ||
return "[object OrderByLimitFeed]"; | ||
}); | ||
return OrderByLimitFeed; | ||
})(IterableResult); | ||
ArrayResult = (function(_super) { | ||
@@ -614,6 +659,8 @@ __extends(ArrayResult, _super); | ||
module.exports.Feed = Feed; | ||
module.exports.AtomFeed = AtomFeed; | ||
module.exports.Feed = Feed; | ||
module.exports.OrderByLimitFeed = OrderByLimitFeed; | ||
module.exports.makeIterable = ArrayResult.prototype.makeIterable; |
103
net.js
@@ -18,3 +18,3 @@ // Generated by CoffeeScript 1.7.0 | ||
protoVersion = protodef.VersionDummy.Version.V0_3; | ||
protoVersion = protodef.VersionDummy.Version.V0_4; | ||
@@ -91,2 +91,3 @@ protoProtocol = protodef.VersionDummy.Protocol.JSON; | ||
this.once('connect', conCallback); | ||
this._closePromise = null; | ||
} | ||
@@ -117,3 +118,3 @@ | ||
Connection.prototype._processResponse = function(response, token) { | ||
var cb, cursor, feed, opts, profile, root, _ref; | ||
var cb, cursor, feed, note, opts, profile, root, _i, _len, _ref, _ref1; | ||
profile = response.p; | ||
@@ -127,7 +128,2 @@ if (this.outstandingCallbacks[token] != null) { | ||
} | ||
} else if (feed != null) { | ||
feed._addResponse(response); | ||
if (feed._endFlag && feed._outstandingRequests === 0) { | ||
return this._delQuery(token); | ||
} | ||
} else if (cb != null) { | ||
@@ -158,3 +154,31 @@ switch (response.t) { | ||
case protoResponseType.SUCCESS_PARTIAL: | ||
cursor = new cursors.Cursor(this, token, opts, root); | ||
cursor = null; | ||
_ref1 = response.n; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
note = _ref1[_i]; | ||
switch (note) { | ||
case protodef.Response.ResponseNote.SEQUENCE_FEED: | ||
if (cursor == null) { | ||
cursor = new cursors.Feed(this, token, opts, root); | ||
} | ||
break; | ||
case protodef.Response.ResponseNote.UNIONED_FEED: | ||
if (cursor == null) { | ||
cursor = new cursors.UnionedFeed(this, token, opts, root); | ||
} | ||
break; | ||
case protodef.Response.ResponseNote.ATOM_FEED: | ||
if (cursor == null) { | ||
cursor = new cursors.AtomFeed(this, token, opts, root); | ||
} | ||
break; | ||
case protodef.Response.ResponseNote.ORDER_BY_LIMIT_FEED: | ||
if (cursor == null) { | ||
cursor = new cursors.OrderByLimitFeed(this, token, opts, root); | ||
} | ||
} | ||
} | ||
if (cursor == null) { | ||
cursor = new cursors.Cursor(this, token, opts, root); | ||
} | ||
this.outstandingCallbacks[token].cursor = cursor; | ||
@@ -182,26 +206,2 @@ if (profile != null) { | ||
break; | ||
case protoResponseType.SUCCESS_FEED: | ||
feed = new cursors.Feed(this, token, opts, root); | ||
this.outstandingCallbacks[token].feed = feed; | ||
if (profile != null) { | ||
return cb(null, { | ||
profile: profile, | ||
value: feed._addResponse(response) | ||
}); | ||
} else { | ||
return cb(null, feed._addResponse(response)); | ||
} | ||
break; | ||
case protoResponseType.SUCCESS_ATOM_FEED: | ||
feed = new cursors.AtomFeed(this, token, opts, root); | ||
this.outstandingCallbacks[token].feed = feed; | ||
if (profile != null) { | ||
return cb(null, { | ||
profile: profile, | ||
value: feed._addResponse(response) | ||
}); | ||
} else { | ||
return cb(null, feed._addResponse(response)); | ||
} | ||
break; | ||
case protoResponseType.WAIT_COMPLETE: | ||
@@ -215,3 +215,3 @@ this._delQuery(token); | ||
} else { | ||
return this.emit('error', new err.RqlDriverError("Unexpected token " + token + ".")); | ||
} | ||
@@ -244,5 +244,19 @@ }; | ||
} | ||
if (this._closePromise != null) { | ||
return this._closePromise.nodeify(cb); | ||
} else if (!this.open) { | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
if (cb != null) { | ||
cb(null, _this); | ||
} else { | ||
} | ||
return process.nextTick(resolve); | ||
}; | ||
})(this)); | ||
} | ||
this.closing = true; | ||
noreplyWait = ((opts.noreplyWait == null) || opts.noreplyWait) && this.open; | ||
return new Promise((function(_this) { | ||
return this._closePromise = new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
@@ -254,2 +268,3 @@ var wrappedCb; | ||
_this.cancel(); | ||
_this._closePromise = null; | ||
if (err != null) { | ||
@@ -314,4 +329,2 @@ return reject(err); | ||
value.cursor._addResponse(response); | ||
} else if (value.feed != null) { | ||
value.feed._addResponse(response); | ||
} else if (value.cb != null) { | ||
@@ -344,4 +357,2 @@ value.cb(mkErr(err.RqlRuntimeError, response, value.root)); | ||
closeCb = function(err) { | ||
_this.rawSocket.removeAllListeners(); | ||
_this.rawSocket = null; | ||
return _this.constructor.call(_this, { | ||
@@ -560,3 +571,4 @@ host: _this.host, | ||
wrappedCb = function(error, result) { | ||
_this.rawSocket.once("close", function() { | ||
var closeCb; | ||
closeCb = function() { | ||
if (error != null) { | ||
@@ -567,4 +579,13 @@ return reject(error); | ||
} | ||
}); | ||
return _this.rawSocket.end(); | ||
}; | ||
if (_this.rawSocket != null) { | ||
_this.rawSocket.once("close", function() { | ||
closeCb(); | ||
_this.rawSocket.removeAllListeners(); | ||
return _this.rawSocket = null; | ||
}); | ||
return _this.rawSocket.end(); | ||
} else { | ||
return process.nextTick(closeCb); | ||
} | ||
}; | ||
@@ -571,0 +592,0 @@ return TcpConnection.__super__.close.call(_this, opts, wrappedCb); |
{ "name" : "rethinkdb" | ||
, "version" : "1.16.2" | ||
, "version" : "2.0.0" | ||
, "main" : "rethinkdb" | ||
@@ -17,3 +17,3 @@ , "description" : "This package provides the JavaScript driver library for the RethinkDB database server for use either from node or your web-browser." | ||
, "engines" : { "node": ">= 0.10.0" } | ||
, "dependencies" : { "bluebird": ">= 2.3.2" } | ||
, "dependencies" : { "bluebird": ">= 2.3.2 < 3" } | ||
} |
@@ -9,3 +9,4 @@ // DO NOT EDIT | ||
V0_2: 1915781601, | ||
V0_3: 1601562686 | ||
V0_3: 1601562686, | ||
V0_4: 1074539808 | ||
}, | ||
@@ -44,8 +45,14 @@ | ||
SUCCESS_PARTIAL: 3, | ||
SUCCESS_FEED: 5, | ||
WAIT_COMPLETE: 4, | ||
SUCCESS_ATOM_FEED: 6, | ||
CLIENT_ERROR: 16, | ||
COMPILE_ERROR: 17, | ||
RUNTIME_ERROR: 18 | ||
}, | ||
ResponseNote: { | ||
SEQUENCE_FEED: 1, | ||
ATOM_FEED: 2, | ||
ORDER_BY_LIMIT_FEED: 3, | ||
UNIONED_FEED: 4, | ||
INCLUDES_STATES: 5 | ||
} | ||
@@ -105,3 +112,3 @@ }, | ||
LIMIT: 71, | ||
INDEXES_OF: 87, | ||
OFFSETS_OF: 87, | ||
CONTAINS: 93, | ||
@@ -116,3 +123,4 @@ GET_FIELD: 31, | ||
MERGE: 35, | ||
BETWEEN: 36, | ||
BETWEEN_DEPRECATED: 36, | ||
BETWEEN: 182, | ||
REDUCE: 37, | ||
@@ -164,4 +172,4 @@ MAP: 38, | ||
BRANCH: 65, | ||
ANY: 66, | ||
ALL: 67, | ||
OR: 66, | ||
AND: 67, | ||
FOR_EACH: 68, | ||
@@ -241,3 +249,5 @@ FUNC: 69, | ||
GET_NEAREST: 168, | ||
POLYGON_SUB: 171 | ||
POLYGON_SUB: 171, | ||
MINVAL: 180, | ||
MAXVAL: 181 | ||
}, | ||
@@ -244,0 +254,0 @@ |
# JavaScript Driver | ||
This package provides first party support for driving a RethinkDB database from a | ||
JavaScript application. It is designed to be run in node.js but will also run in | ||
the latest versions of Chrome and Firefox. | ||
This package is the officially supported driver for querying a | ||
RethinkDB database from a JavaScript application. It is designed to | ||
be run in Node.js but also has an alternate http connection type that | ||
is used by the RethinkDB web ui. The http connection type is not | ||
intended to be used by applications, since it isn't secure. | ||
Ultimately, the http connection type will move into the web ui code | ||
and out of the driver. | ||
Checkout [www.rethinkdb.com/api/](http://www.rethinkdb.com/api/) for documentation and examples of using this | ||
driver. | ||
Check out | ||
[rethinkdb.com/api/javascript](http://www.rethinkdb.com/api/javascript) | ||
for documentation and examples of using this driver. | ||
## Creating the proto-def.js | ||
To build the JavaScript driver, you'll need to first generate the | ||
definitions file `proto-def.js`. To do that from the `drivers` | ||
directory, you can do: | ||
```bash | ||
$ ./convert_protofile -l javascript \ | ||
-i ../src/rdb_protocol/ql2.proto \ | ||
-o ./javascript/proto-def.js | ||
``` |
@@ -149,3 +149,3 @@ // Generated by CoffeeScript 1.7.0 | ||
var i, key, value, _i, _len; | ||
if (obj instanceof Array) { | ||
if (Array.isArray(obj)) { | ||
for (i = _i = 0, _len = obj.length; _i < _len; i = ++_i) { | ||
@@ -155,3 +155,3 @@ value = obj[i]; | ||
} | ||
} else if (obj instanceof Object) { | ||
} else if (obj && typeof obj === 'object') { | ||
for (key in obj) { | ||
@@ -158,0 +158,0 @@ value = obj[key]; |
Sorry, the diff of this file is too big to display
182202
5302
26
+ Addedbluebird@2.11.0(transitive)
- Removedbluebird@3.7.2(transitive)
Updatedbluebird@>= 2.3.2 < 3