Skip to content

Commit 747def4

Browse files
author
enikon
authored
[Feature] OAS-10537 Allow for Bulk Adding of Vertices to VertexCollection and Edges to EdgeCollection (#657)
* Edges and VertexCollection as a separate interface GraphCollection * Added comments with information about the incompatibility of SmartGraphs/EnterpriseGraphs with v1 document collection
1 parent 93c5033 commit 747def4

12 files changed

+386
-10
lines changed

v2/arangodb/collection_documents_create.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2020-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -36,13 +36,15 @@ type CollectionDocumentCreate interface {
3636
// If the document data already contains a `_key` field, this will be used as key of the new document,
3737
// otherwise a unique key is created.
3838
// A ConflictError is returned when a `_key` field contains a duplicate key, other any other field violates an index constraint.
39+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
3940
CreateDocument(ctx context.Context, document interface{}) (CollectionDocumentCreateResponse, error)
4041

4142
// CreateDocumentWithOptions creates a single document in the collection.
4243
// The document data is loaded from the given document, the document metadata is returned.
4344
// If the document data already contains a `_key` field, this will be used as key of the new document,
4445
// otherwise a unique key is created.
4546
// A ConflictError is returned when a `_key` field contains a duplicate key, other any other field violates an index constraint.
47+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4648
CreateDocumentWithOptions(ctx context.Context, document interface{}, options *CollectionDocumentCreateOptions) (CollectionDocumentCreateResponse, error)
4749

4850
// CreateDocuments creates multiple documents in the collection.
@@ -55,6 +57,7 @@ type CollectionDocumentCreate interface {
5557
// a slice with the same number of entries as the `documents` slice.
5658
// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
5759
// If the create request itself fails or one of the arguments is invalid, an error is returned.
60+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
5861
CreateDocuments(ctx context.Context, documents interface{}) (CollectionDocumentCreateResponseReader, error)
5962

6063
// CreateDocumentsWithOptions creates multiple documents in the collection.
@@ -67,6 +70,7 @@ type CollectionDocumentCreate interface {
6770
// a slice with the same number of entries as the `documents` slice.
6871
// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
6972
// If the create request itself fails or one of the arguments is invalid, an error is returned.
73+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
7074
CreateDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentCreateOptions) (CollectionDocumentCreateResponseReader, error)
7175
}
7276

v2/arangodb/collection_documents_delete.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2023-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -33,22 +33,26 @@ type CollectionDocumentDelete interface {
3333
// DeleteDocument removes a single document with given key from the collection.
3434
// The document metadata is returned.
3535
// If no document exists with given key, a NotFoundError is returned.
36+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
3637
DeleteDocument(ctx context.Context, key string) (CollectionDocumentDeleteResponse, error)
3738

3839
// DeleteDocumentWithOptions removes a single document with given key from the collection.
3940
// The document metadata is returned.
4041
// If no document exists with given key, a NotFoundError is returned.
42+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4143
DeleteDocumentWithOptions(ctx context.Context, key string, opts *CollectionDocumentDeleteOptions) (CollectionDocumentDeleteResponse, error)
4244

4345
// DeleteDocuments removes multiple documents with given keys from the collection.
4446
// The document metadata are returned.
4547
// If no document exists with a given key, a NotFoundError is returned at its errors index.
48+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4649
DeleteDocuments(ctx context.Context, keys []string) (CollectionDocumentDeleteResponseReader, error)
4750

4851
// DeleteDocumentsWithOptions removes multiple documents with given keys from the collection.
4952
// The document metadata are returned.
5053
// If no document exists with a given key, a NotFoundError is returned at its errors index.
5154
// 'documents' must be a slice of structs with a `_key` field or a slice of keys.
55+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
5256
DeleteDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentDeleteOptions) (CollectionDocumentDeleteResponseReader, error)
5357
}
5458

v2/arangodb/collection_documents_read.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2020-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -33,23 +33,27 @@ type CollectionDocumentRead interface {
3333
// ReadDocument reads a single document with given key from the collection.
3434
// The document data is stored into result, the document metadata is returned.
3535
// If no document exists with given key, a NotFoundError is returned.
36+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
3637
ReadDocument(ctx context.Context, key string, result interface{}) (DocumentMeta, error)
3738

3839
// ReadDocumentWithOptions reads a single document with given key from the collection.
3940
// The document data is stored into result, the document metadata is returned.
4041
// If no document exists with given key, a NotFoundError is returned.
42+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4143
ReadDocumentWithOptions(ctx context.Context, key string, result interface{}, opts *CollectionDocumentReadOptions) (DocumentMeta, error)
4244

4345
// ReadDocuments reads multiple documents with given keys from the collection.
4446
// The documents data is stored into elements of the given results slice,
4547
// the documents metadata is returned.
4648
// If no document exists with a given key, a NotFoundError is returned at its errors index.
49+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4750
ReadDocuments(ctx context.Context, keys []string) (CollectionDocumentReadResponseReader, error)
4851

4952
// ReadDocumentsWithOptions reads multiple documents with given keys from the collection.
5053
// The documents data is stored into elements of the given results slice and the documents metadata is returned.
5154
// If no document exists with a given key, a NotFoundError is returned at its errors index.
5255
// 'documents' must be a slice of structs with a `_key` field or a slice of keys.
56+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
5357
ReadDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentReadOptions) (CollectionDocumentReadResponseReader, error)
5458
}
5559

v2/arangodb/collection_documents_replace.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2023-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -34,25 +34,29 @@ type CollectionDocumentReplace interface {
3434
// ReplaceDocument replaces a single document with given key in the collection.
3535
// If no document exists with given key, a NotFoundError is returned.
3636
// If `_id` field is present in the document body, it is always ignored.
37+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
3738
ReplaceDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentReplaceResponse, error)
3839

3940
// ReplaceDocumentWithOptions replaces a single document with given key in the collection.
4041
// If no document exists with given key, a NotFoundError is returned.
4142
// If `_id` field is present in the document body, it is always ignored.
43+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4244
ReplaceDocumentWithOptions(ctx context.Context, key string, document interface{}, options *CollectionDocumentReplaceOptions) (CollectionDocumentReplaceResponse, error)
4345

4446
// ReplaceDocuments replaces multiple document with given keys in the collection.
4547
// The replaces are loaded from the given replaces slice, the documents metadata are returned.
4648
// If no document exists with a given key, a NotFoundError is returned at its errors index.
4749
// Each element in the replaces slice must contain a `_key` field.
4850
// If `_id` field is present in the document body, it is always ignored.
51+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4952
ReplaceDocuments(ctx context.Context, documents interface{}) (CollectionDocumentReplaceResponseReader, error)
5053

5154
// ReplaceDocumentsWithOptions replaces multiple document with given keys in the collection.
5255
// The replaces are loaded from the given replaces slice, the documents metadata are returned.
5356
// If no document exists with a given key, a NotFoundError is returned at its errors index.
5457
// Each element in the replaces slice must contain a `_key` field.
5558
// If `_id` field is present in the document body, it is always ignored.
59+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
5660
ReplaceDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentReplaceOptions) (CollectionDocumentReplaceResponseReader, error)
5761
}
5862

v2/arangodb/collection_documents_update.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2020-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -34,26 +34,30 @@ type CollectionDocumentUpdate interface {
3434
// The document metadata is returned.
3535
// If no document exists with a given key, a NotFoundError is returned.
3636
// If `_id` field is present in the document body, it is always ignored.
37+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
3738
UpdateDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentUpdateResponse, error)
3839

3940
// UpdateDocumentWithOptions updates a single document with a given key in the collection.
4041
// The document metadata is returned.
4142
// If no document exists with a given key, a NotFoundError is returned.
4243
// If `_id` field is present in the document body, it is always ignored.
44+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
4345
UpdateDocumentWithOptions(ctx context.Context, key string, document interface{}, options *CollectionDocumentUpdateOptions) (CollectionDocumentUpdateResponse, error)
4446

4547
// UpdateDocuments updates multiple documents
4648
// The updates are loaded from the given updates slice, the documents metadata are returned.
4749
// If no document exists with a given key, a NotFoundError is returned at its errors index.
4850
// Each element in the update slice must contain a `_key` field.
4951
// If `_id` field is present in the document body, it is always ignored.
52+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
5053
UpdateDocuments(ctx context.Context, documents interface{}) (CollectionDocumentUpdateResponseReader, error)
5154

5255
// UpdateDocumentsWithOptions updates multiple documents
5356
// The updates are loaded from the given updates slice, the documents metadata are returned.
5457
// If no document exists with a given key, a NotFoundError is returned at its errors index.
5558
// Each element in the update slice must contain a `_key` field.
5659
// If `_id` field is present in the document body, it is always ignored.
60+
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
5761
UpdateDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentUpdateOptions) (CollectionDocumentUpdateResponseReader, error)
5862
}
5963

v2/arangodb/graph_collection.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package arangodb
22+
23+
import (
24+
"context"
25+
)
26+
27+
type GraphCollection interface {
28+
Name() string
29+
Database() Database
30+
31+
// Count fetches the number of document in the collection.
32+
Count(ctx context.Context) (int64, error)
33+
34+
CollectionDocuments
35+
CollectionIndexes
36+
}

v2/arangodb/graph_edge_definitions_edges.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@ import (
2727
)
2828

2929
type Edge interface {
30+
GraphCollection
31+
3032
// Name returns the name of the Edge collection
3133
Name() string
3234

v2/arangodb/graph_edge_definitions_edges_impl.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -32,12 +32,15 @@ func newEdgeCollection(edge *graph, edgeColName string) *edgeCollection {
3232
return &edgeCollection{
3333
graph: edge,
3434
edgeColName: edgeColName,
35+
collection: *newCollection(edge.db, edgeColName, edge.modifiers...),
3536
}
3637
}
3738

3839
var _ Edge = &edgeCollection{}
3940

4041
type edgeCollection struct {
42+
collection
43+
4144
edgeColName string
4245

4346
modifiers []connection.RequestModifier

v2/arangodb/graph_vertex_collections_vertices.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@ import (
2727
)
2828

2929
type VertexCollection interface {
30+
GraphCollection
31+
3032
// Name returns the name of the vertex collection
3133
Name() string
3234

v2/arangodb/graph_vertex_collections_vertices_impl.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -32,12 +32,15 @@ func newVertexCollection(vertex *graph, vertexColName string) *vertexCollection
3232
return &vertexCollection{
3333
graph: vertex,
3434
vertexColName: vertexColName,
35+
collection: *newCollection(vertex.db, vertexColName, vertex.modifiers...),
3536
}
3637
}
3738

3839
var _ VertexCollection = &vertexCollection{}
3940

4041
type vertexCollection struct {
42+
collection
43+
4144
vertexColName string
4245

4346
modifiers []connection.RequestModifier

0 commit comments

Comments
 (0)