181 |
warn "## database: $database id: $id -> $p ", dump( $arg ),"\n"; |
warn "## database: $database id: $id -> $p ", dump( $arg ),"\n"; |
182 |
|
|
183 |
|
|
184 |
if ( $id =~ m{_all_docs(\w+)?$} ) { |
if ( $id =~ m{_all_docs(\w*)$} ) { |
185 |
|
|
186 |
my $by = $1; |
my $by = $1; |
187 |
my $offset = 0; |
my $offset = 0; |
191 |
my $total_rows = 0; |
my $total_rows = 0; |
192 |
|
|
193 |
my @docs = grep { length $_ } map { |
my @docs = grep { length $_ } map { |
194 |
return '' if defined $limit && $total_rows == $limit; |
|
195 |
|
if ( $limit > 0 && $total_rows == $limit ) { |
196 |
|
''; |
197 |
|
} else { |
198 |
|
|
199 |
s{^$path/$database/}{}; |
s{^$path/$database/}{}; |
|
return '' if defined $endkey && $_ gt $endkey; |
|
200 |
|
|
201 |
if ( $startkey ) { |
if ( defined $endkey && $_ gt $endkey ) { |
202 |
if ( $_ ge $startkey ) { |
''; |
203 |
|
} elsif ( $startkey ) { |
204 |
|
if ( $_ ge $startkey ) { |
205 |
|
$total_rows++; |
206 |
|
$_; |
207 |
|
} else { |
208 |
|
$offset++; |
209 |
|
''; |
210 |
|
} |
211 |
|
} else { |
212 |
$total_rows++; |
$total_rows++; |
213 |
$_; |
$_; |
|
} else { |
|
|
$offset++; |
|
|
return ''; |
|
214 |
} |
} |
|
} else { |
|
|
$total_rows++; |
|
|
$_; |
|
215 |
} |
} |
216 |
|
|
217 |
} glob( "$path/$database/*" ); |
} glob( "$path/$database/*" ); |
218 |
|
|
219 |
|
|
220 |
warn "## docs $startkey -> $endkey limit $limit ", dump( @docs ); # if $debug; |
warn "## docs $startkey -> $endkey limit $limit ", dump( @docs ); # if $debug; |
221 |
|
|
222 |
$json = { |
$json = { |
256 |
push @{ $json->{rows} }, $rows->{$id}; |
push @{ $json->{rows} }, $rows->{$id}; |
257 |
} |
} |
258 |
|
|
259 |
|
$status = 200; |
260 |
|
|
261 |
} elsif ( $method eq 'PUT' ) { |
} elsif ( $method eq 'PUT' ) { |
262 |
|
|
263 |
warn "## ",dump( $tx->req ); # if $debug; |
warn "## ",dump( $tx->req ); # if $debug; |