arangodb / arangodb

🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.
https://www.arangodb.com
Other
13.57k stars 836 forks source link

How to save record in edgeCollection in ArangoDb3.2 #3503

Closed Gaurav664067 closed 6 years ago

Gaurav664067 commented 7 years ago

I am using node js server side. | I want to store value in edgeCollection whenever We are storing any value in an particular collection.

It was working in AurangoDB 2.8 version but getting issue in Arango3.2. Error are as below.

{ error: true, code: 404, errorNum: 404, errorMessage: 'unknown path \'/_api/edge?collection=offerCollection&from=userCollection%2FnhRJ2VYARet5AepC4vOMuO5Nm4F1BG&to=serviceCollection%2F4863\'' }, rawBody: '{"error":true,"code":404,"errorNum":404,"errorMessage":"unknown path \'/_api/edge?collection=offerCollection&from=userCollection%2FnhRJ2VYARet5AepC4vOMuO5Nm4F1BG&to=serviceCollection%2F4863\'"}' } }

Simran-B commented 7 years ago

The API changed in 3.0, see https://docs.arangodb.com/3.2/Manual/ReleaseNotes/UpgradingChanges30.html#http-api-changes

Edges API

CRUD operations

The API for documents and edges have been unified in ArangoDB 3.0. The CRUD operations for documents and edges are now handled by the same endpoint at /_api/document. For CRUD operations there is no distinction anymore between documents and edges API-wise.

That means CRUD operations concerning edges need to be sent to the HTTP endpoint /_api/document instead of /_api/edge. Sending requests to /_api/edge will result in an HTTP 404 error in 3.0. The following methods are available at /_api/document for documents and edge:

  • HTTP POST: insert new document or edge
  • HTTP GET: fetch an existing document or edge
  • HTTP PUT: replace an existing document or edge
  • HTTP PATCH: partially update an existing document or edge
  • HTTP DELETE: remove an existing document or edge

When completely replacing an edge via HTTP PUT please note that the replacing edge data now needs to contain the _from and _to attributes for the edge. Previous versions of ArangoDB did not require sending _from and _to when replacing edges, as _from and _to values were immutable for existing edges.

The _from and _to attributes of edges now also need to be present inside the edges objects sent to the server:

curl -X POST \
     --data '{"value":1,"_from":"myVertexCollection/1","_to":"myVertexCollection/2"}' \
     "http://127.0.0.1:8529/_api/document?collection=myEdgeCollection"

Previous versions of ArangoDB required the _from and _to attributes of edges be sent separately in URL parameter from and to:

curl -X POST \
     --data '{"value":1}' \
     "http://127.0.0.1:8529/_api/edge?collection=e&from=myVertexCollection/1&to=myVertexCollection/2"
Simran-B commented 6 years ago

@Gaurav664067 Were you able to fix the issue?

maxkernbach commented 6 years ago

I am closing this issue for now since we have not received any feedback for a few months. As Simran pointed out, the cause of your problem is an API change when upgrading from 2.8 to 3.2.