Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] OAS-10537 Allow for Bulk Adding of Vertices to VertexCollection and Edges to EdgeCollection #657

Merged
6 changes: 5 additions & 1 deletion v2/arangodb/collection_documents_create.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2020-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,13 +36,15 @@ type CollectionDocumentCreate interface {
// If the document data already contains a `_key` field, this will be used as key of the new document,
// otherwise a unique key is created.
// A ConflictError is returned when a `_key` field contains a duplicate key, other any other field violates an index constraint.
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
CreateDocument(ctx context.Context, document interface{}) (CollectionDocumentCreateResponse, error)

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion v2/arangodb/collection_documents_delete.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,22 +33,26 @@ type CollectionDocumentDelete interface {
// DeleteDocument removes a single document with given key from the collection.
// The document metadata is returned.
// If no document exists with given key, a NotFoundError is returned.
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
DeleteDocument(ctx context.Context, key string) (CollectionDocumentDeleteResponse, error)

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion v2/arangodb/collection_documents_read.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2020-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,23 +33,27 @@ type CollectionDocumentRead interface {
// ReadDocument reads a single document with given key from the collection.
// The document data is stored into result, the document metadata is returned.
// If no document exists with given key, a NotFoundError is returned.
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
ReadDocument(ctx context.Context, key string, result interface{}) (DocumentMeta, error)

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion v2/arangodb/collection_documents_replace.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,25 +34,29 @@ type CollectionDocumentReplace interface {
// ReplaceDocument replaces a single document with given key in the collection.
// If no document exists with given key, a NotFoundError is returned.
// If `_id` field is present in the document body, it is always ignored.
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
ReplaceDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentReplaceResponse, error)

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion v2/arangodb/collection_documents_update.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2020-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,26 +34,30 @@ type CollectionDocumentUpdate interface {
// The document metadata is returned.
// If no document exists with a given key, a NotFoundError is returned.
// If `_id` field is present in the document body, it is always ignored.
// SmartGraphs and Enterprise Graphs cannot use existing collections and cannot use the document interface
UpdateDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentUpdateResponse, error)

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

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

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

Expand Down
36 changes: 36 additions & 0 deletions v2/arangodb/graph_collection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// DISCLAIMER
//
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package arangodb

import (
"context"
)

type GraphCollection interface {
Name() string
Database() Database

// Count fetches the number of document in the collection.
Count(ctx context.Context) (int64, error)

CollectionDocuments
CollectionIndexes
}
4 changes: 3 additions & 1 deletion v2/arangodb/graph_edge_definitions_edges.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -27,6 +27,8 @@ import (
)

type Edge interface {
GraphCollection

// Name returns the name of the Edge collection
Name() string

Expand Down
5 changes: 4 additions & 1 deletion v2/arangodb/graph_edge_definitions_edges_impl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,12 +32,15 @@ func newEdgeCollection(edge *graph, edgeColName string) *edgeCollection {
return &edgeCollection{
graph: edge,
edgeColName: edgeColName,
collection: *newCollection(edge.db, edgeColName, edge.modifiers...),
}
}

var _ Edge = &edgeCollection{}

type edgeCollection struct {
collection

edgeColName string

modifiers []connection.RequestModifier
Expand Down
4 changes: 3 additions & 1 deletion v2/arangodb/graph_vertex_collections_vertices.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -27,6 +27,8 @@ import (
)

type VertexCollection interface {
GraphCollection

// Name returns the name of the vertex collection
Name() string

Expand Down
5 changes: 4 additions & 1 deletion v2/arangodb/graph_vertex_collections_vertices_impl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,12 +32,15 @@ func newVertexCollection(vertex *graph, vertexColName string) *vertexCollection
return &vertexCollection{
graph: vertex,
vertexColName: vertexColName,
collection: *newCollection(vertex.db, vertexColName, vertex.modifiers...),
}
}

var _ VertexCollection = &vertexCollection{}

type vertexCollection struct {
collection

vertexColName string

modifiers []connection.RequestModifier
Expand Down
Loading