1 |
|
2 | var debug = require('./_debug');
|
3 |
|
4 |
|
5 | function putExtractor( cb ){
|
6 |
|
7 |
|
8 | var extractor = function( error, resp ){
|
9 |
|
10 |
|
11 | debug.resp( resp );
|
12 |
|
13 |
|
14 | if( error ) return cb( error );
|
15 |
|
16 |
|
17 | if( 'object' == typeof resp && resp.hasOwnProperty('error') ) return cb( resp.error );
|
18 |
|
19 |
|
20 | else if( 'object' == typeof resp && resp.created === true && resp.hasOwnProperty('_id') ){
|
21 | var output = {
|
22 | _index: resp._index,
|
23 | _type: resp._type,
|
24 | _id: resp._id
|
25 | }
|
26 | return cb( undefined, output );
|
27 | }
|
28 |
|
29 |
|
30 | else return cb( undefined, false );
|
31 | }
|
32 |
|
33 | return extractor;
|
34 | }
|
35 |
|
36 | module.exports = putExtractor; |
\ | No newline at end of file |