@@ -274,46 +274,9 @@ export function RethinkDBAdapter (opts) {
274
274
this . r || ( this . r = rethinkdbdash ( this . rOpts ) )
275
275
}
276
276
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 ,
315
279
316
- utils . addHiddenPropsToTarget ( RethinkDBAdapter . prototype , {
317
280
_handleErrors ( cursor ) {
318
281
if ( cursor && cursor . errors > 0 ) {
319
282
if ( cursor . first_error ) {
@@ -1113,3 +1076,56 @@ export const version = '<%= version %>'
1113
1076
*
1114
1077
* @module js-data-rethinkdb
1115
1078
*/
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