sub new_uuid { Time::HiRes::time * 100000 }
-# based on
-# http://docs.getangular.com/REST.Basic
-# http://angular.getangular.com/data
-
-push @{app->static->paths}, 'app';
+push @{app->static->paths}, 'app'; # default angular-seed app directory
my $couchdb = $ENV{COUCHDB} || 'http://localhost:5984';
my $database = $self->param('database');
my $entity = $self->param('entity');
my $json = $self->req->json;
- my $id = $json->{'$id'} # XXX we don't get it back from angular.js
- || new_uuid;
+ my $id = $1 if $json->{'_id'} =~ m/^\Q$entity\E\.(.+)$/;
+ $id ||= new_uuid;
warn "## $database $entity $id body ",dump($self->req->body, $json);
- $json->{'$id'} ||= $id; # make sure $id is in there
-
my $new = _couchdb_put "/$database/$entity.$id" => $json;
warn "new: ",dump($new);
if ( $new->{ok} ) {