my $database = $self->param('database');
my $entity = $self->param('entity');
my $json = $self->req->json;
- my $id = $1 if $json->{'_id'} =~ m/^\Q$entity\E\.(.+)$/;
- $id ||= new_uuid;
+ my $id;
+ if ( exists $json->{'id'} ) { # @id in resource
+ $id = $json->{'id'};
+ warn "EXISTING $id\n";
+ } else {
+ $id = $json->{'id'} = new_uuid;
+ $json->{entity} = $entity;
+ warn "NEW $id\n";
+ }
warn "## $database $entity $id body ",dump($self->req->body, $json);
my $new = _couchdb_put "/$database/$entity.$id" => $json;