projects
/
angular-drzb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
cd8c451
)
correctly extract regitration id from _id
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 7 Dec 2012 15:10:25 +0000
(16:10 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 7 Dec 2012 15:10:25 +0000
(16:10 +0100)
angular-server.pl
patch
|
blob
|
history
diff --git
a/angular-server.pl
b/angular-server.pl
index
1daf2ef
..
62c2651
100755
(executable)
--- a/
angular-server.pl
+++ b/
angular-server.pl
@@
-10,11
+10,7
@@
use Mojo::UserAgent;
sub new_uuid { Time::HiRes::time * 100000 }
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 $couchdb = $ENV{COUCHDB} || 'http://localhost:5984';
@@
-127,12
+123,10
@@
any [ 'post' ] => '/data/:database/:entity' => sub {
my $database = $self->param('database');
my $entity = $self->param('entity');
my $json = $self->req->json;
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);
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} ) {
my $new = _couchdb_put "/$database/$entity.$id" => $json;
warn "new: ",dump($new);
if ( $new->{ok} ) {