Skip to content

Commit 4edd918

Browse files
authored
Doc update (#571)
1 parent fbf5680 commit 4edd918

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

collection_documents.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2017-2023 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.
@@ -17,8 +17,6 @@
1717
//
1818
// Copyright holder is ArangoDB GmbH, Cologne, Germany
1919
//
20-
// Author Ewout Prangsma
21-
//
2220

2321
package driver
2422

@@ -67,6 +65,7 @@ type CollectionDocuments interface {
6765
// To return the OLD document, prepare a context with `WithReturnOld`.
6866
// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
6967
// If no document exists with given key, a NotFoundError is returned.
68+
// If `_id` field is present in the document body, it is always ignored.
7069
UpdateDocument(ctx context.Context, key string, update interface{}) (DocumentMeta, error)
7170

7271
// UpdateDocuments updates multiple document with given keys in the collection.
@@ -75,7 +74,8 @@ type CollectionDocuments interface {
7574
// To return the OLD documents, prepare a context with `WithReturnOld` with a slice of documents.
7675
// To wait until documents has been synced to disk, prepare a context with `WithWaitForSync`.
7776
// If no document exists with a given key, a NotFoundError is returned at its errors index.
78-
// If keys is nil, each element in the updates slice must contain a `_key` field.
77+
// If keys are nil, each element in the update slice must contain a `_key` field.
78+
// If `_id` field is present in the document body, it is always ignored.
7979
UpdateDocuments(ctx context.Context, keys []string, updates interface{}) (DocumentMetaSlice, ErrorSlice, error)
8080

8181
// ReplaceDocument replaces a single document with given key in the collection with the document given in the document argument.
@@ -84,6 +84,7 @@ type CollectionDocuments interface {
8484
// To return the OLD document, prepare a context with `WithReturnOld`.
8585
// To wait until document has been synced to disk, prepare a context with `WithWaitForSync`.
8686
// If no document exists with given key, a NotFoundError is returned.
87+
// If `_id` field is present in the document body, it is always ignored.
8788
ReplaceDocument(ctx context.Context, key string, document interface{}) (DocumentMeta, error)
8889

8990
// ReplaceDocuments replaces multiple documents with given keys in the collection with the documents given in the documents argument.
@@ -93,6 +94,7 @@ type CollectionDocuments interface {
9394
// To wait until documents has been synced to disk, prepare a context with `WithWaitForSync`.
9495
// If no document exists with a given key, a NotFoundError is returned at its errors index.
9596
// If keys is nil, each element in the documents slice must contain a `_key` field.
97+
// If `_id` field is present in the document body, it is always ignored.
9698
ReplaceDocuments(ctx context.Context, keys []string, documents interface{}) (DocumentMetaSlice, ErrorSlice, error)
9799

98100
// RemoveDocument removes a single document with given key from the collection.

examples/example_client_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ func ExampleNewClient() {
5656
fmt.Printf("Database has version '%s' and license '%s'\n", versionInfo.Version, versionInfo.License)
5757
}
5858

59-
// ExampleNewClientWithAuthentication shows how to create the client with custom connection configuration
59+
// ExampleNewConnection shows how to create the client with custom connection configuration
60+
// If there is more than one endpoint, the client will pick the first one that works and use it till it fails.
61+
// Then it will try the next one.
6062
func ExampleNewConnection() {
6163
// Create an HTTP connection to the database
6264
conn, err := drviverHttp.NewConnection(drviverHttp.ConnectionConfig{
63-
Endpoints: []string{"http://localhost:8529"},
65+
Endpoints: []string{"http://localhost:8529", "http://localhost:8539"},
6466
Transport: NewConnectionTransport(),
6567
})
6668
if err != nil {

http/connection.go

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const (
5454
type ConnectionConfig struct {
5555
// Endpoints holds 1 or more URL's used to connect to the database.
5656
// In case of a connection to an ArangoDB cluster, you must provide the URL's of all coordinators.
57+
// If there is more than one endpoint, the client will pick the first one that works and use it till it fails.
58+
// Then it will try the next one
5759
Endpoints []string
5860
// TLSConfig holds settings used to configure a TLS (HTTPS) connection.
5961
// This is only used for endpoints using the HTTPS scheme.

v2/arangodb/collection_documents_replace.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,26 @@ type CollectionDocumentReplace interface {
3333

3434
// ReplaceDocument replaces a single document with given key in the collection.
3535
// If no document exists with given key, a NotFoundError is returned.
36+
// If `_id` field is present in the document body, it is always ignored.
3637
ReplaceDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentReplaceResponse, error)
3738

3839
// ReplaceDocumentWithOptions replaces a single document with given key in the collection.
3940
// If no document exists with given key, a NotFoundError is returned.
41+
// If `_id` field is present in the document body, it is always ignored.
4042
ReplaceDocumentWithOptions(ctx context.Context, key string, document interface{}, options *CollectionDocumentReplaceOptions) (CollectionDocumentReplaceResponse, error)
4143

4244
// ReplaceDocuments replaces multiple document with given keys in the collection.
4345
// The replaces are loaded from the given replaces slice, the documents metadata are returned.
4446
// If no document exists with a given key, a NotFoundError is returned at its errors index.
4547
// Each element in the replaces slice must contain a `_key` field.
48+
// If `_id` field is present in the document body, it is always ignored.
4649
ReplaceDocuments(ctx context.Context, documents interface{}) (CollectionDocumentReplaceResponseReader, error)
4750

4851
// ReplaceDocumentsWithOptions replaces multiple document with given keys in the collection.
4952
// The replaces are loaded from the given replaces slice, the documents metadata are returned.
5053
// If no document exists with a given key, a NotFoundError is returned at its errors index.
5154
// Each element in the replaces slice must contain a `_key` field.
55+
// If `_id` field is present in the document body, it is always ignored.
5256
ReplaceDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentReplaceOptions) (CollectionDocumentReplaceResponseReader, error)
5357
}
5458

v2/arangodb/collection_documents_update.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,30 @@ import (
3030
// CollectionDocumentUpdate Partially updates document(s) with given key in the collection.
3131
// https://www.arangodb.com/docs/devel/http/document.html#update-a-document
3232
type CollectionDocumentUpdate interface {
33-
34-
// UpdateDocument updates a single document with given key in the collection.
33+
// UpdateDocument updates a single document with a given key in the collection.
3534
// The document metadata is returned.
36-
// If no document exists with given key, a NotFoundError is returned.
35+
// If no document exists with a given key, a NotFoundError is returned.
36+
// If `_id` field is present in the document body, it is always ignored.
3737
UpdateDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentUpdateResponse, error)
3838

39-
// UpdateDocumentWithOptions updates a single document with given key in the collection.
39+
// UpdateDocumentWithOptions updates a single document with a given key in the collection.
4040
// The document metadata is returned.
41-
// If no document exists with given key, a NotFoundError is returned.
41+
// If no document exists with a given key, a NotFoundError is returned.
42+
// If `_id` field is present in the document body, it is always ignored.
4243
UpdateDocumentWithOptions(ctx context.Context, key string, document interface{}, options *CollectionDocumentUpdateOptions) (CollectionDocumentUpdateResponse, error)
4344

4445
// UpdateDocuments updates multiple documents
4546
// The updates are loaded from the given updates slice, the documents metadata are returned.
4647
// If no document exists with a given key, a NotFoundError is returned at its errors index.
47-
// Each element in the updates slice must contain a `_key` field.
48+
// Each element in the update slice must contain a `_key` field.
49+
// If `_id` field is present in the document body, it is always ignored.
4850
UpdateDocuments(ctx context.Context, documents interface{}) (CollectionDocumentUpdateResponseReader, error)
4951

5052
// UpdateDocumentsWithOptions updates multiple documents
5153
// The updates are loaded from the given updates slice, the documents metadata are returned.
5254
// If no document exists with a given key, a NotFoundError is returned at its errors index.
53-
// Each element in the updates slice must contain a `_key` field.
55+
// Each element in the update slice must contain a `_key` field.
56+
// If `_id` field is present in the document body, it is always ignored.
5457
UpdateDocumentsWithOptions(ctx context.Context, documents interface{}, opts *CollectionDocumentUpdateOptions) (CollectionDocumentUpdateResponseReader, error)
5558
}
5659

0 commit comments

Comments
 (0)