http://angularjs.org/Service:$resource
+Server also supports replication using same API which can be triggered with
+
+ http://localhost:3000/_replicate?from=http://dpavlin.getangular.com/data/conference/
+
+Replication is currently good only for initial import of data since it doesn't
+support incremental replication and dies if data is allready present.
+
Installation:
if ( my $from = $self->param('from') ) {
my $got = $self->client->get( $from )->res->json;
warn "# from $from ",dump($got);
- _render_jsonp( $self, $got );
my $database = $got->{name};
my $entities = $got->{entities};
my $url = $from;
$url =~ s{/?$}{/}; # add slash at end
$url .= $entity;
- my $e = $self->client->get( $url )->res->json;
- warn "# replicated $url ", dump($e);
- _chouchdb_put( $self, $database, $entity, $e->{'$id'}, $e );
+ my $all = $self->client->get( $url )->res->json;
+ warn "# replicated $url ", dump($all);
+ foreach my $e ( @$all ) {
+ delete $e->{_id}; # sanitize data from older implementation
+ _couchdb_put( "/$database/$entity." . $e->{'$id'} => $e );
+ }
}
}
+ _render_jsonp( $self, $got );
}
};