@@ -33,6 +33,7 @@ function Multilevel (path, opts) {
33
33
this . _encode = lpstream . encode ( )
34
34
this . _streaming = null
35
35
this . _ref = null
36
+ this . _db = null
36
37
}
37
38
38
39
util . inherits ( Multilevel , abstract . AbstractLevelDOWN )
@@ -115,6 +116,10 @@ Multilevel.prototype.createRpcStream = function (opts, proxy) {
115
116
}
116
117
}
117
118
119
+ Multilevel . prototype . forward = function ( down ) {
120
+ this . _db = down
121
+ }
122
+
118
123
Multilevel . prototype . isFlushed = function ( ) {
119
124
return ! this . _requests . length && ! this . _iterators . length
120
125
}
@@ -141,6 +146,8 @@ Multilevel.prototype._clearRequests = function (closing) {
141
146
}
142
147
143
148
Multilevel . prototype . _get = function ( key , opts , cb ) {
149
+ if ( this . _db ) return this . _db . _get ( key , opts , cb )
150
+
144
151
var req = {
145
152
tag : 0 ,
146
153
id : 0 ,
@@ -154,6 +161,8 @@ Multilevel.prototype._get = function (key, opts, cb) {
154
161
}
155
162
156
163
Multilevel . prototype . _put = function ( key , value , opts , cb ) {
164
+ if ( this . _db ) return this . _db . _put ( key , value , opts , cb )
165
+
157
166
var req = {
158
167
tag : 1 ,
159
168
id : 0 ,
@@ -167,6 +176,8 @@ Multilevel.prototype._put = function (key, value, opts, cb) {
167
176
}
168
177
169
178
Multilevel . prototype . _del = function ( key , opts , cb ) {
179
+ if ( this . _db ) return this . _db . _del ( key , opts , cb )
180
+
170
181
var req = {
171
182
tag : 2 ,
172
183
id : 0 ,
@@ -179,6 +190,8 @@ Multilevel.prototype._del = function (key, opts, cb) {
179
190
}
180
191
181
192
Multilevel . prototype . _batch = function ( batch , opts , cb ) {
193
+ if ( this . _db ) return this . _db . _batch ( batch , opts , cb )
194
+
182
195
var req = {
183
196
tag : 3 ,
184
197
id : 0 ,
@@ -200,6 +213,8 @@ Multilevel.prototype._write = function (req) {
200
213
}
201
214
202
215
Multilevel . prototype . _close = function ( cb ) {
216
+ if ( this . _db ) return this . _close ( cb )
217
+
203
218
this . _clearRequests ( true )
204
219
if ( this . _streaming ) {
205
220
this . _streaming . once ( 'close' , cb )
@@ -210,6 +225,7 @@ Multilevel.prototype._close = function (cb) {
210
225
}
211
226
212
227
Multilevel . prototype . _iterator = function ( opts ) {
228
+ if ( this . _db ) return this . _iterator ( opts )
213
229
return new Iterator ( this , opts )
214
230
}
215
231
0 commit comments