Skip to content

Commit 731d06d

Browse files
committed
Merge branch 'master' into release
2 parents 31dd8d0 + 52c7a4a commit 731d06d

File tree

4 files changed

+65
-44
lines changed

4 files changed

+65
-44
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 3.0.0-beta.8 - 08 July 2016
2+
3+
###### Backwards compatible changes
4+
- RethinkDBAdapter now inherits from Adapter via the `extend` method
5+
16
##### 3.0.0-beta.7 - 29 June 2016
27

38
###### Backwards compatible changes

circle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ machine:
88
dependencies:
99
pre:
1010
- npm i -g npm codecov nyc
11-
- npm i js-data@^3.0.0-beta.5 rethinkdbdash
11+
- npm i js-data@^3.0.0-beta.10 rethinkdbdash
1212
- source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
1313
- wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
1414
- sudo apt-get update -qq

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-rethinkdb",
33
"description": "RethinkDB adapter for js-data.",
4-
"version": "3.0.0-beta.7",
4+
"version": "3.0.0-beta.8",
55
"homepage": "https://github.com/js-data/js-data-rethinkdb",
66
"repository": {
77
"type": "git",
@@ -59,14 +59,14 @@
5959
"release": "npm test && npm run doc && repo-tools updates && repo-tools changelog && repo-tools authors"
6060
},
6161
"dependencies": {
62-
"js-data-adapter": "~0.7.3",
62+
"js-data-adapter": "~0.7.4",
6363
"mout": "1.0.0"
6464
},
6565
"peerDependencies": {
66-
"js-data": "^3.0.0-beta.8",
66+
"js-data": "^3.0.0-beta.10",
6767
"rethinkdbdash": ">=2.0.0"
6868
},
6969
"devDependencies": {
70-
"js-data-repo-tools": "0.5.4"
70+
"js-data-repo-tools": "0.5.5"
7171
}
7272
}

src/index.js

+55-39
Original file line numberDiff line numberDiff line change
@@ -274,46 +274,9 @@ export function RethinkDBAdapter (opts) {
274274
this.r || (this.r = rethinkdbdash(this.rOpts))
275275
}
276276

277-
// Setup prototype inheritance from Adapter
278-
RethinkDBAdapter.prototype = Object.create(Adapter.prototype, {
279-
constructor: {
280-
value: RethinkDBAdapter,
281-
enumerable: false,
282-
writable: true,
283-
configurable: true
284-
}
285-
})
286-
287-
Object.defineProperty(RethinkDBAdapter, '__super__', {
288-
configurable: true,
289-
value: Adapter
290-
})
291-
292-
/**
293-
* Alternative to ES6 class syntax for extending `RethinkDBAdapter`.
294-
*
295-
* @example <caption>Using the ES2015 class syntax.</caption>
296-
* class MyRethinkDBAdapter extends RethinkDBAdapter {...}
297-
* const adapter = new MyRethinkDBAdapter()
298-
*
299-
* @example <caption>Using {@link RethinkDBAdapter.extend}.</caption>
300-
* var instanceProps = {...}
301-
* var classProps = {...}
302-
*
303-
* var MyRethinkDBAdapter = RethinkDBAdapter.extend(instanceProps, classProps)
304-
* var adapter = new MyRethinkDBAdapter()
305-
*
306-
* @method RethinkDBAdapter.extend
307-
* @static
308-
* @param {Object} [instanceProps] Properties that will be added to the
309-
* prototype of the subclass.
310-
* @param {Object} [classProps] Properties that will be added as static
311-
* properties to the subclass itself.
312-
* @return {Constructor} Subclass of `RethinkDBAdapter`.
313-
*/
314-
RethinkDBAdapter.extend = utils.extend
277+
Adapter.extend({
278+
constructor: RethinkDBAdapter,
315279

316-
utils.addHiddenPropsToTarget(RethinkDBAdapter.prototype, {
317280
_handleErrors (cursor) {
318281
if (cursor && cursor.errors > 0) {
319282
if (cursor.first_error) {
@@ -1113,3 +1076,56 @@ export const version = '<%= version %>'
11131076
*
11141077
* @module js-data-rethinkdb
11151078
*/
1079+
1080+
/**
1081+
* Create a subclass of this RethinkDBAdapter:
1082+
* @example <caption>RethinkDBAdapter.extend</caption>
1083+
* // Normally you would do: import {RethinkDBAdapter} from 'js-data-rethinkdb'
1084+
* const JSDataRethinkDB = require('[email protected]')
1085+
* const {RethinkDBAdapter} = JSDataRethinkDB
1086+
* console.log('Using JSDataRethinkDB v' + JSDataRethinkDB.version.full)
1087+
*
1088+
* // Extend the class using ES2015 class syntax.
1089+
* class CustomRethinkDBAdapterClass extends RethinkDBAdapter {
1090+
* foo () { return 'bar' }
1091+
* static beep () { return 'boop' }
1092+
* }
1093+
* const customRethinkDBAdapter = new CustomRethinkDBAdapterClass()
1094+
* console.log(customRethinkDBAdapter.foo())
1095+
* console.log(CustomRethinkDBAdapterClass.beep())
1096+
*
1097+
* // Extend the class using alternate method.
1098+
* const OtherRethinkDBAdapterClass = RethinkDBAdapter.extend({
1099+
* foo () { return 'bar' }
1100+
* }, {
1101+
* beep () { return 'boop' }
1102+
* })
1103+
* const otherRethinkDBAdapter = new OtherRethinkDBAdapterClass()
1104+
* console.log(otherRethinkDBAdapter.foo())
1105+
* console.log(OtherRethinkDBAdapterClass.beep())
1106+
*
1107+
* // Extend the class, providing a custom constructor.
1108+
* function AnotherRethinkDBAdapterClass () {
1109+
* RethinkDBAdapter.call(this)
1110+
* this.created_at = new Date().getTime()
1111+
* }
1112+
* RethinkDBAdapter.extend({
1113+
* constructor: AnotherRethinkDBAdapterClass,
1114+
* foo () { return 'bar' }
1115+
* }, {
1116+
* beep () { return 'boop' }
1117+
* })
1118+
* const anotherRethinkDBAdapter = new AnotherRethinkDBAdapterClass()
1119+
* console.log(anotherRethinkDBAdapter.created_at)
1120+
* console.log(anotherRethinkDBAdapter.foo())
1121+
* console.log(AnotherRethinkDBAdapterClass.beep())
1122+
*
1123+
* @method RethinkDBAdapter.extend
1124+
* @param {Object} [props={}] Properties to add to the prototype of the
1125+
* subclass.
1126+
* @param {Object} [props.constructor] Provide a custom constructor function
1127+
* to be used as the subclass itself.
1128+
* @param {Object} [classProps={}] Static properties to add to the subclass.
1129+
* @returns {Constructor} Subclass of this RethinkDBAdapter class.
1130+
* @since 3.0.0
1131+
*/

0 commit comments

Comments
 (0)