Categorygithub.com/ravendb/ravendb-go-client
modulepackage
0.0.0-20240723121956-2b87f37fe427
Repository: https://github.com/ravendb/ravendb-go-client.git
Documentation: pkg.go.dev

# README

compile

This is information on how to use the library. For docs on working on the library itself see readme-dev.md.

This library requires go 1.11 or later.

API reference: https://godoc.org/github.com/ravendb/ravendb-go-client

This library is in beta state. All the basic functionality works and passes extensive test suite, but the API for more esoteric features might change.

If you encounter bugs, have suggestions or feature requests, please open an issue.

Documentation

To learn basics of RavenDB, read RavenDB Documentation or Dive into RavenDB.

Getting started

Full source code of those examples is in examples directory.

To run a a specific example, e.g. crudStore, you can run:

  • .\scripts\run_example.ps1 crudStore : works on mac / linux if you have powershell installed
  • go run examples\log.go examples\main.go crudStore : on mac / linux change paths to examples/log.go etc.
  1. Import the package
import (
	ravendb "github.com/ravendb/ravendb-go-client"
)
  1. Initialize document store (you should have one DocumentStore instance per application)
func getDocumentStore(databaseName string) (*ravendb.DocumentStore, error) {
	serverNodes := []string{"http://live-test.ravendb.net"}
	store := ravendb.NewDocumentStore(serverNodes, databaseName)
	if err := store.Initialize(); err != nil {
		return nil, err
	}
	return store, nil
}

To setup an document store with security, you'll need to provide the client certificate for authentication. Here is how to setup a document store with a certificate:

func getDocumentStore(databaseName string) (*ravendb.DocumentStore, error) {
	cerPath := "/path/to/certificate.crt"
	keyPath := "/path/to/certificate.key"
	serverNodes := []string{"https://a.tasty.ravendb.run", 
		"https://b.tasty.ravendb.run", "https://c.tasty.ravendb.run"}

	cer, err := tls.LoadX509KeyPair(cerPath, keyPath)
	if err != nil {
		return nil, err
	}
	store := ravendb.NewDocumentStore(serverNodes, databaseName)
	store.Certificate = &cer
	x509cert, err :=  x509.ParseCertificate(cer.Certificate[0])
	if err != nil {
		return nil, err
	}
	store.TrustStore = x509cert
	if err := store.Initialize(); err != nil {
		return nil, err
	}
	return store, nil
}

If you are using an encrypted certificate, see the sample code on how to translate that to tls.Certificate here: https://play.golang.org/p/8OYTuZtZIQ

  1. Open a session and close it when done
session, err = store.OpenSession()
if err != nil {
	log.Fatalf("store.OpenSession() failed with %s", err)
}
// ... use session
session.Close()
  1. Call SaveChanges() to persist changes in a session:
var e *northwind.Employee
err = session.Load(&e, "employees/7-A")
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}

origName := e.FirstName
e.FirstName = e.FirstName + "Changed"
err = session.Store(e)
if err != nil {
    log.Fatalf("session.Store() failed with %s\n", err)
}

err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with %s\n", err)
}

var e2 *northwind.Employee
err = session.Load(&e2, "employees/7-A")
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}
fmt.Printf("Updated Employee.FirstName from '%s' to '%s'\n", origName, e2.FirstName)

See loadUpdateSave() in examples/main.go for full example.

CRUD example

Storing documents

product := &northwind.Product{
    Name:         "iPhone X",
    PricePerUnit: 999.99,
    Category:     "electronis",
    ReorderLevel: 15,
}
err = session.Store(product)
if err != nil {
    log.Fatalf("session.Store() failed with %s\n", err)
}

See crudStore() in examples/main.go for full example.

Loading documents

var e *northwind.Employee
err = session.Load(&e, "employees/7-A")
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}
fmt.Printf("employee: %#v\n", e)

See crudLoad() in examples/main.go for full example.

Loading documents with includes

Some entities point to other entities via id. For example Employee has ReportsTo field which is an id of Employee that it reports to.

To improve performance by minimizing number of server requests, we can use includes functionality to load such linked entities.

// load employee with id "employees/7-A" and entity whose id is ReportsTo
var e *northwind.Employee
err = session.Include("ReportsTo").Load(&e, "employees/5-A")
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}
if e.ReportsTo == "" {
    fmt.Printf("Employee with id employees/5-A doesn't report to anyone\n")
    return
}

numRequests := session.GetNumberOfRequests()
var reportsTo *northwind.Employee
err = session.Load(&reportsTo, e.ReportsTo)
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}
if numRequests != session.GetNumberOfRequests() {
    fmt.Printf("Something's wrong, this shouldn't send a request to the server\n")
} else {
    fmt.Printf("Loading e.ReportsTo employee didn't require a new request to the server because we've loaded it in original requests thanks to using Include functionality\n")
}

See crudLoadWithInclude() in examples/main.go for full example.

Updating documents

// load entity from the server
var p *northwind.Product
err = session.Load(&p, productID)
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}

// update price
origPrice = p.PricePerUnit
newPrice = origPrice + 10
p.PricePerUnit = newPrice
err = session.Store(p)
if err != nil {
    log.Fatalf("session.Store() failed with %s\n", err)
}

// persist changes on the server
err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with %s\n", err)
}

See crudUpdate() in examples/main.go for full example.

Deleting documents

Delete using entity:

// ... store a product and remember its id in productID

var p *northwind.Product
err = session.Load(&p, productID)
if err != nil {
    log.Fatalf("session.Load() failed with %s\n", err)
}

err = session.Delete(p)
if err != nil {
    log.Fatalf("session.Delete() failed with %s\n", err)
}

err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with %s\n", err)
}

See crudDeleteUsingEntity() in examples/main.go for full example.

Entity must be a value that we either stored in the database in the current session via Store() or loaded from database using Load(), LoadMulti(), query etc.

Delete using id:

// ... store a product and remember its id in productID

err = session.DeleteByID(productID, "")
if err != nil {
    log.Fatalf("session.Delete() failed with %s\n", err)
}

err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with %s\n", err)
}

Second argument to DeleteByID is optional changeVector, for fine-grain concurrency control.

See crudDeleteUsingID() in examples/main.go for full example.

Querying documents

Selecting what to query

First you need to decide what to query.

RavenDB stores documents in collections. By default each type (struct) is stored in its own collection e.g. all Employee structs are stored in employees collection.

You can query by collection name:

q := session.QueryCollection("employees")

See queryCollectionByName() in examples/main.go for full example.

To get a collection name for a given type use ravendb.GetCollectionNameDefault(&MyStruct{}).

You can query a collection for a given type:

tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)

See queryCollectionByType() in examples/main.go for full example.

You can query an index:

q := session.QueryIndex("Orders/ByCompany")

See queryIndex() in examples/main.go for full example.

Limit what is returned

tp := reflect.TypeOf(&northwind.Product{})
q := session.QueryCollectionForType(tp)

q = q.WaitForNonStaleResults(0)
q = q.WhereEquals("Name", "iPhone X")
q = q.OrderBy("PricePerUnit")
q = q.Take(2) // limit to 2 results

See queryComplex() in examples/main.go for full example.

Obtain the results

You can get all matching results:

var products []*northwind.Product
err = q.GetResults(&products)

See queryComplex() in examples/main.go for full example.

You can get just first one:

var first *northwind.Employee
err = q.First(&first)

See queryFirst() in examples/main.go for full example.

Overview of DocumentQuery methods

SelectFields() - projections using a single field

// RQL equivalent: from employees select FirstName
q = q.SelectFields(reflect.TypeOf(""), "FirstName")

var names []string
err = q.GetResults(&names)

See querySelectSingleField() in examples/main.go for full example.

SelectFields() - projections using multiple fields

type employeeNameTitle struct {
	FirstName string
	Title     string
}

// RQL equivalent: from employees select FirstName, Title
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.SelectFields(reflect.TypeOf(&employeeNameTitle{}), "FirstName", "Title")

See querySelectFields() in examples/main.go for full example.

Distinct()

// RQL equivalent: from employees select distinct Title
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.SelectFields(reflect.TypeOf(""), "Title")
q = q.Distinct()

See queryDistinct() in examples/main.go for full example.

WhereEquals() / WhereNotEquals()

// RQL equivalent: from employees where Title = 'Sales Representative'
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereEquals("Title", "Sales Representative")

See queryEquals() in examples/main.go for full example.

WhereIn

// RQL equivalent: from employees where Title in ['Sales Representative', 'Sales Manager']
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereIn("Title", []interface{}{"Sales Representative", "Sales Manager"})

See queryIn() in examples/main.go for full example.

WhereStartsWith() / WhereEndsWith()

// RQL equivalent:
// from employees where startsWith('Ro')
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereStartsWith("FirstName", "Ro")

See queryStartsWith() and queryEndsWith in examples/main.go for full example.

WhereBetween()

// RQL equivalent:
// from orders where Freight between 11 and 13
tp := reflect.TypeOf(&northwind.Order{})
q := session.QueryCollectionForType(tp)
q = q.WhereBetween("Freight", 11, 13)

See queryBetween() in examples/main.go for full example.

WhereGreaterThan() / WhereGreaterThanOrEqual() / WhereLessThan() / WhereLessThanOrEqual()

// RQL equivalent:
// from orders where Freight Freight > 11
tp := reflect.TypeOf(&northwind.Order{})
q := session.QueryCollectionForType(tp)
// can also be WhereGreaterThanOrEqual(), WhereLessThan(), WhereLessThanOrEqual()
q = q.WhereGreaterThan("Freight", 11)

See queryGreater() in examples/main.go for full example.

WhereExists()

Checks if the field exists.

// RQL equivalent:
// from employees where exists ("ReportsTo")
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereExists("ReportsTo")

See queryExists() in examples/main.go for full example.

ContainsAny() / ContainsAll()

// RQL equivalent:
// from employees where FirstName in ("Anne", "Nancy")
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.ContainsAny("FirstName", []interface{}{"Anne", "Nancy"})

See queryContainsAny() in examples/main.go for full example.

Search()

Performs full-text search:

// RQL equivalent:
// from employees where search(FirstName, 'Anne Nancy')
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.Search("FirstName", "Anne Nancy")

See querySearch() in examples/main.go for full example.

OpenSubclause() / CloseSubclause()

// RQL equivalent:
// from employees where (FirstName = 'Steven') or (Title = 'Sales Representative' and LastName = 'Davolio')
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereEquals("FirstName", "Steven")
q = q.OrElse()
q = q.OpenSubclause()
q = q.WhereEquals("Title", "Sales Representative")
q = q.WhereEquals("LastName", "Davolio")
q = q.CloseSubclause()

See querySubclause() in examples/main.go for full example.

Not()

// RQL equivalent:
// from employees where not FirstName = 'Steven'
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.Not()
q = q.WhereEquals("FirstName", "Steven")

See queryNot() in examples/main.go for full example.

AndAlso() / OrElse()

// RQL equivalent:
// from employees where FirstName = 'Steven' or FirstName  = 'Nancy'
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereEquals("FirstName", "Steven")
// can also be AndElse()
q = q.OrElse()
q = q.WhereEquals("FirstName", "Nancy")

See queryOrElse() in examples/main.go for full example.

UsingDefaultOperator()

Sets default operator (which will be used if no AndAlso() / OrElse() was called. Just after query instantiation, OR is used as default operator. Default operator can be changed only adding any conditions.

OrderBy() / RandomOrdering()

// RQL equivalent:
// from employees order by FirstName
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
// can also be RandomOrdering()
q = q.OrderBy("FirstName")

See queryOrderBy() in examples/main.go for full example.

Take()

// RQL equivalent:
// from employees order by FirstName desc
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.OrderByDescending("FirstName")
q = q.Take(2)

See queryTake() in examples/main.go for full example.

Skip()

// RQL equivalent:
// from employees order by FirstName desc
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.OrderByDescending("FirstName")
q = q.Take(2)
q = q.Skip(1)

See querySkip() in examples/main.go for full example.

Getting query statistics

To obtain query statistics use Statistics() method.

var stats *ravendb.QueryStatistics
tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
q = q.WhereGreaterThan("FirstName", "Bernard")
q = q.OrderByDescending("FirstName")
q.Statistics(&stats)

Statistics:

Statistics:
{IsStale:           false,
 DurationInMs:      0,
 TotalResults:      7,
 SkippedResults:    0,
 Timestamp:         2019-02-13 02:57:31.5226409 +0000 UTC,
 IndexName:         "Auto/employees/ByLastNameAndReportsToAndSearch(FirstName)AndTitle",
 IndexTimestamp:    2019-02-13 02:57:31.5226409 +0000 UTC,
 LastQueryTime:     2019-02-13 03:50:25.7602429 +0000 UTC,
 TimingsInMs:       {},
 ResultEtag:        7591488513381790088,
 ResultSize:        0,
 ScoreExplanations: {}}

See queryStatistics() in examples/main.go for full example.

GetResults() / First() / Single() / Count()

GetResults() - returns all results

First() - first result

Single() - first result, returns error if there's more entries

Count() - returns the number of the results (not affected by take())

See queryFirst(), querySingle() and queryCount() in examples/main.go for full example.

Attachments

Store attachments

fileStream, err := os.Open(path)
if err != nil {
    log.Fatalf("os.Open() failed with '%s'\n", err)
}
defer fileStream.Close()

fmt.Printf("new employee id: %s\n", e.ID)
err = session.Advanced().Attachments().Store(e, "photo.png", fileStream, "image/png")

// could also be done using document id
// err = session.Advanced().Attachments().Store(e.ID, "photo.png", fileStream, "image/png")

if err != nil {
    log.Fatalf("session.Advanced().Attachments().Store() failed with '%s'\n", err)
}

err = session.SaveChanges()

See storeAttachments() in examples/main.go for full example.

Get attachments

attachment, err := session.Advanced().Attachments().Get(docID, "photo.png")
if err != nil {
    log.Fatalf("session.Advanced().Attachments().Get() failed with '%s'\n", err)
}
defer attachment.Close()
fmt.Print("Attachment details:\n")
pretty.Print(attachment.Details)
// read attachment data
// attachment.Data is io.Reader
var attachmentData bytes.Buffer
n, err := io.Copy(&attachmentData, attachment.Data)
if err != nil {
    log.Fatalf("io.Copy() failed with '%s'\n", err)
}
fmt.Printf("Attachment size: %d bytes\n", n)

Attachment details:

{AttachmentName: {Name:        "photo.png",
                  Hash:        "MvUEcrFHSVDts5ZQv2bQ3r9RwtynqnyJzIbNYzu1ZXk=",
                  ContentType: "image/png",
                  Size:        4579},
 ChangeVector:   "A:4905-dMAeI9ANZ06DOxCRLnSmNw",
 DocumentID:     "employees/44-A"}
Attachment size: 4579 bytes

See getAttachments() in examples/main.go for full example.

Check if attachment exists

name := "photo.png"
exists, err := session.Advanced().Attachments().Exists(docID, name)
if err != nil {
    log.Fatalf("session.Advanced().Attachments().Exists() failed with '%s'\n", err)
}

See checkAttachmentExists() in examples/main.go for full example.

Get attachment names

names, err := session.Advanced().Attachments().GetNames(doc)
if err != nil {
    log.Fatalf("session.Advanced().Attachments().GetNames() failed with '%s'\n", err)
}

Attachment names:

[{Name:        "photo.png",
  Hash:        "MvUEcrFHSVDts5ZQv2bQ3r9RwtynqnyJzIbNYzu1ZXk=",
  ContentType: "image/png",
  Size:        4579}]

See getAttachmentNames() in examples/main.go for full example.

Bulk insert

When storing multiple documents, use bulk insertion.

bulkInsert := store.BulkInsert("")

names := []string{"Anna", "Maria", "Miguel", "Emanuel", "Dayanara", "Aleida"}
for _, name := range names {
    e := &northwind.Employee{
        FirstName: name,
    }
    id, err := bulkInsert.Store(e, nil)
    if err != nil {
        log.Fatalf("bulkInsert.Store() failed with '%s'\n", err)
    }
}
// flush data and finish
err = bulkInsert.Close()

See bulkInsert() in examples/main.go for full example.

Observing changes in the database

Listen for database changes e.g. document changes.

changes := store.Changes("")

err = changes.EnsureConnectedNow()
if err != nil {
    log.Fatalf("changes.EnsureConnectedNow() failed with '%s'\n", err)
}

cb := func(change *ravendb.DocumentChange) {
    fmt.Print("change:\n")
    pretty.Print(change)
}
docChangesCancel, err := changes.ForAllDocuments(cb)
if err != nil {
    log.Fatalf("changes.ForAllDocuments() failed with '%s'\n", err)
}

defer docChangesCancel()

e := &northwind.Employee{
    FirstName: "Jon",
    LastName:  "Snow",
}
err = session.Store(e)
if err != nil {
    log.Fatalf("session.Store() failed with '%s'\n", err)
}

err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with '%s'\n", err)
}
// cb should now be called notifying there's a new document

Example change:

{Type:           "Put",
 ID:             "Raven/Hilo/employees",
 CollectionName: "@hilo",
 ChangeVector:   "A:4892-bJERJNLunE+4xQ/yDEuk1Q"}

See changes() in examples/main.go for full example.

Streaming

Streaming allows interating over documents matching certain criteria.

It's useful when there's a large number of results as it limits memory use by reading documents in batches (as opposed to all at once).

Stream documents with ID prefix

Here we iterate over all documents in products collection:

args := &ravendb.StartsWithArgs{
    StartsWith: "products/",
}
iterator, err := session.Advanced().Stream(args)
if err != nil {
    log.Fatalf("session.Advanced().Stream() failed with '%s'\n", err)
}
for {
    var p *northwind.Product
    streamResult, err := iterator.Next(&p)
    if err != nil {
        // io.EOF means there are no more results
        if err == io.EOF {
            err = nil
        } else {
            log.Fatalf("iterator.Next() failed with '%s'\n", err)
        }
        break
    }
    // handle p
}

See streamWithIDPrefix() in examples/main.go for full example.

This returns:

streamResult:
{ID:           "products/1-A",
 ChangeVector: "A:96-bJERJNLunE+4xQ/yDEuk1Q",
 Metadata:     {},
 Document:     ... same as product but as map[string]interface{} ...

product:
{ID:              "products/1-A",
 Name:            "Chai",
 Supplier:        "suppliers/1-A",
 Category:        "categories/1-A",
 QuantityPerUnit: "10 boxes x 20 bags",
 PricePerUnit:    18,
 UnitsInStock:    1,
 UnistsOnOrder:   0,
 Discontinued:    false,
 ReorderLevel:    10}

Stream query results

tp := reflect.TypeOf(&northwind.Product{})
q := session.QueryCollectionForType(tp)
q = q.WhereGreaterThan("PricePerUnit", 15)
q = q.OrderByDescending("PricePerUnit")

iterator, err := session.Advanced().StreamQuery(q, nil)
if err != nil {
    log.Fatalf("session.Advanced().StreamQuery() failed with '%s'\n", err)
}
// rest of processing as above

See streamQueryResults() in examples/main.go for full example.

Revisions

Note: make sure to enable revisions in a given store using NewConfigureRevisionsOperation operation.

e := &northwind.Employee{
    FirstName: "Jon",
    LastName:  "Snow",
}
err = session.Store(e)
if err != nil {
    log.Fatalf("session.Store() failed with '%s'\n", err)
}
err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with '%s'\n", err)
}

// modify document to create a new revision
e.FirstName = "Jhonny"
err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with '%s'\n", err)
}

var revisions []*northwind.Employee
err = session.Advanced().Revisions().GetFor(&revisions, e.ID)

See revisions() in examples/main.go for full example.

Returns:

[{ID:          "employees/43-A",
  LastName:    "Snow",
  FirstName:   "Jhonny",
  Title:       "",
  Address:     nil,
  HiredAt:     {},
  Birthday:    {},
  HomePhone:   "",
  Extension:   "",
  ReportsTo:   "",
  Notes:       [],
  Territories: []},
 {ID:          "employees/43-A",
  LastName:    "Snow",
  FirstName:   "Jon",
  Title:       "",
  Address:     nil,
  HiredAt:     {},
  Birthday:    {},
  HomePhone:   "",
  Extension:   "",
  ReportsTo:   "",
  Notes:       [],
  Territories: []}]

Suggestions

Suggestions provides similarity queries. Here we're asking for FirstName values similar to Micael and the database suggests Michael.

index := ravendb.NewIndexCreationTask("EmployeeIndex")
index.Map = "from doc in docs.Employees select new { doc.FirstName }"
index.Suggestion("FirstName")

err = store.ExecuteIndex(index, "")
if err != nil {
    log.Fatalf("store.ExecuteIndex() failed with '%s'\n", err)
}

tp := reflect.TypeOf(&northwind.Employee{})
q := session.QueryCollectionForType(tp)
su := ravendb.NewSuggestionWithTerm("FirstName")
su.Term = "Micael"
suggestionQuery := q.SuggestUsing(su)
results, err := suggestionQuery.Execute()

See suggestions() in examples/main.go for full example.

Returns:

{FirstName: {Name:        "FirstName",
             Suggestions: ["michael"]}}

Advanced patching

To update documents more efficiently than sending the whole document, you can patch just a given field or atomically add/substract values of numeric fields.

err = session.Advanced().IncrementByID(product.ID, "PricePerUnit", 15)
if err != nil {
    log.Fatalf("session.Advanced().IncrementByID() failed with %s\n", err)
}

err = session.Advanced().Patch(product, "Category", "expensive products")
if err != nil {
    log.Fatalf("session.Advanced().PatchEntity() failed with %s\n", err)
}

err = session.SaveChanges()
if err != nil {
    log.Fatalf("session.SaveChanges() failed with %s\n", err)
}

See advancedPatching() in examples/main.go for full example.

Subscriptions

opts := ravendb.SubscriptionCreationOptions{
    Query: "from Products where PricePerUnit > 17 and PricePerUnit < 19",
}
subscriptionName, err := store.Subscriptions().Create(&opts, "")
if err != nil {
    log.Fatalf("store.Subscriptions().Create() failed with %s\n", err)
}
wopts := ravendb.NewSubscriptionWorkerOptions(subscriptionName)
worker, err := store.Subscriptions().GetSubscriptionWorker(tp, wopts, "")
if err != nil {
    log.Fatalf("store.Subscriptions().GetSubscriptionWorker() failed with %s\n", err)
}

results := make(chan *ravendb.SubscriptionBatch, 16)
cb := func(batch *ravendb.SubscriptionBatch) error {
    results <- batch
    return nil
}
err = worker.Run(cb)
if err != nil {
    log.Fatalf("worker.Run() failed with %s\n", err)
}

// wait for first batch result
select {
case batch := <-results:
    fmt.Print("Batch of subscription results:\n")
    pretty.Print(batch)
case <-time.After(time.Second * 5):
    fmt.Printf("Timed out waiting for first subscription batch\n")

}

_ = worker.Close()

See subscriptions() in examples/main.go for full example.

Cluster wide transactions

Setup a session

To set session transaction as cluster wide you've to set TransactionMode in SessionOptions as TransactionMode_ClusterWide

session, err := store.OpenSessionWithOptions(&ravendb.SessionOptions{
    Database:        "",
    RequestExecutor: nil,
    TransactionMode: ravendb.TransactionMode_ClusterWide,
    DisableAtomicDocumentWritesInClusterWideTransaction: nil,
})

Cluster transactions

In order to create cluster transactions you have to get cluster transaction object from your session or you can use it as fluent API.

clusterTransaction := session.Advanced().ClusterTransaction()

In case of wrong session configuration clusterTransaction object will be nil.

Inserting new CompareExchangeValue

objectToInsert := &YourStruct{[...]}
key := "exampleKeyOfItem"
value, error := session.Advanced().ClusterTransaction().CreateCompareExchangeValue(key, objectToInsert)

Getting existing CompareExchangeValue from server

You can retrieve your value using various methods.

- Get value by key

dataType := reflect.TypeOf(&YourStruct{}) // identifies your data-struct type
key := "exampleKeyOfItem"
value, error := session.Advanced().ClusterTransaction().GetCompareExchangeValue(dataType, key)

- Get values by keys

dataType := reflect.TypeOf(&YourStruct{}) // identifies your data-struct type
keys := []string{"item/1", "item/2"}
value, error := session.Advanced().ClusterTransaction().GetCompareExchangeValuesWithKeys(dataType, keys)

Returns map where keys are identifiers.

Get values whose IDs start with a string

dataType := reflect.TypeOf(&YourStruct{}) // identifies your data-struct type
startsWith := "item/"
start := 0
pageSize := 25
values, error := session.Advanced().ClusterTransaction().GetCompareExchangeValues(dataType, startsWith, start, pageSize)

Returns map where keys are identifiers.

Delete CompareExchangeValue

By field key and index

key := "item/1"
index := 5
err := session.Advanced().ClusterTransaction().DeleteCompareExchangeValueByKey(key, index)

By CompareExchangeValue object

var compareExchangeValue *ravendb.CompareExchangeValue

//Load by API
compareExchangeValue , error := session.Advanced().ClusterTransaction().GetCompareExchangeValue[...]

err := session.Advanced().ClusterTransaction().DeleteCompareExchangeValue(compareExchangeValue)

Operations

Configure expiration operation

Options:

type ExpirationConfiguration struct {
	Disabled             bool   `json:"Disabled"`
	DeleteFrequencyInSec *int64 `json:"DeleteFrequencyInSec"`
	MaxItemsToProcess    *int64 `json:"MaxItemsToProcess"`
}

Operation creation is available by passing the ExpirationConfiguration object:

configureExpiration := ravendb.ExpirationConfiguration{
    Disabled: false,
}
//Method: NewConfigureExpirationOperationWithConfiguration(expirationConfiguration *ExpirationConfiguration) (*ConfigureExpirationOperation, error)
operation, err := ravendb.NewConfigureExpirationOperationWithConfiguration(&configureExpiration)

Or directly by passing parameters:

var deleteFrequency int64 = 60
//Method: func NewConfigureExpirationOperation(disabled bool, deleteFrequencyInSec *int64, maxItemsToProcess *int64) (*ConfigureExpirationOperation, error) 
opExpiration, err = ravendb.NewConfigureExpirationOperation(false, &deleteFrequency, nil)

Operation returns object:

type ExpirationConfigurationResult struct {
	RaftCommandIndex *int64 `json:"RaftCommandIndex"`
}

Example of usage:

var deleteFrequency int64 = 60
opExpiration, err = ravendb.NewConfigureExpirationOperation(false, &deleteFrequency, nil)
assert.NoError(t, err)

err = store.Maintenance().Send(opExpiration)
assert.NoError(t, err)

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
CmpXchgValue returns CmpXchg for a given key.
FieldsFor returns names of all fields for the value of a struct type.
GetCollectionNameDefault is a default way of.
GetWrappedError returns an error wrapped by this error If no error is wrapped, returns nil.
IsPlural retruns true if word is plural.
IsSingular returns true if a word is singular.
NewBatchOptions returns new BatchOptions.
NewBulkInsertCommand returns new BulkInsertCommand.
NewBulkInsertOperation returns new BulkInsertOperation.
NewCartesianBoundingBoxIndex returns cartesian SpatialOptions.
NewCartesianQuadPrefixTreeIndex returns cartesian SpatialOptions for quad prefix tree index.
NewCircleCriteria returns new CircleCriteria.
No description provided by the author
No description provided by the author
NewCompactDatabaseCommand returns new CompactDatabaseCommand.
NewCompactDatabaseOperation returns new CompactDatabaseOperation.
No description provided by the author
No description provided by the author
NewCompareExchangeValue returns new CompareExchangeValue.
No description provided by the author
No description provided by the author
No description provided by the author
NewConfigureRevisionsCommand returns new ConfigureRevisionsCommand.
NewConfigureRevisionsOperation returns new ConfigureRevisionsOperation.
NewCreateDatabaseCommand returns new CreateDatabaseCommand.
NewCreateDatabaseOperation returns CreateDatabaseOperation.
NewCreateSampleDataCommand returns new CreateSampleDataCommand.
NewCreateSampleDataOperation.
No description provided by the author
NewDatabaseRecord returns new database record.
No description provided by the author
NewDeleteAttachmentCommandData creates CommandData for Delete Attachment command.
No description provided by the author
No description provided by the author
No description provided by the author
NewDeleteCommandData creates ICommandData for Delete command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewDocumentConventions creates DocumentConventions with default values.
NewDocumentSession creates a new DocumentSession.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewExternalReplication creates ExternalReplication.
NewFacet returns a new Facet.
No description provided by the author
No description provided by the author
NewFacetOptions returns new FacetOptions.
NewGenericRangeFacet returns new GenericRangeFacet parent is optional, can be nil.
NewGeographyBoundingBoxIndexWithRadius return geography SpatialOptions for a bounding box with a given radius.
NewGeographyDefaultOptions returns default geography SpatialOptions.
NewGeographyDefaultOptionsWithRadius returns default geography SpatialOptions with a a given radius.
NewGeographyGeohashPrefixTreeIndex returns geography SpatialOptions for using geography geohash prefix tree index.
NewGeographyGeohashPrefixTreeIndexWithRadius returns geography SpatialOptions for using geography geohash prefix tree index with a given circle radius.
NewGeographyQuadPrefixTreeIndex returns geography SpatialOptions for quad prefix tree.
NewGeographyQuadPrefixTreeIndex returns geography SpatialOptions for quad prefix tree with a given radius.
NewGeograpyboundingBoxIndex returns geography SpatialOptions for a bounding box.
TODO: should stream be io.ReadCloser? Who owns closing the attachment.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewGetNextOperationIDCommand returns GetNextOperationIDCommand.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewGetTcpInfoCommand returns new GetTcpInfoCommand dbName is optional.
NewGetTermsCommand returns new GetTermsCommand.
NewGetTermsOperation returns GetTermsOperation.
NewGroupByField returns new GroupBy for an array.
NewGroupByField returns new GroupBy for a field.
No description provided by the author
NewHeadDocumentCommand returns new HeadDocumentCommand.
NewHiLoIDGenerator creates a HiLoIDGenerator.
NewHiLoReturnCommand returns a new HiLoReturnCommand.
No description provided by the author
No description provided by the author
NewAbstractIndexCreationTask returns new IndexCreationTask.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
from IndexQuery.
No description provided by the author
NewJavaScriptArray creates a new JavaScriptArray.
NewKillOperationCommand returns new KillOperationCommand.
NewLazyMultiLoaderWithInclude creates a lazy multi loader with includes.
NewLazyStartsWithOperation returns new LazyStartsWithOperation TODO: convert to use StartsWithArgs.
No description provided by the author
No description provided by the author
No description provided by the author
NewMetadataAsDictionary returns MetadataAsDictionary based on a given metadata and parent.
NewMetadataAsDictionaryWithMetadata returns MetadataAsDictionary based on a given metadata.
NewMetadataAsDictionaryWithSource returns MetadataAsDictionary based on a given source.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewMultiDatabaseHiLoIDGenerator creates new MultiDatabaseHiLoKeyGenerator.
No description provided by the author
NewMultiTypeHiLoIDGenerator creates MultiTypeHiLoKeyGenerator.
NewNextHiLoCommand returns new NextHiLoCommand.
No description provided by the author
NewNodeSelector creates a new NodeSelector.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewPatchCommand returns new PatchCommand.
NewPatchCommandData creates CommandData for Delete Attachment command TODO: return a concrete type?.
NewPatchOperation returns new PatchOperation.
No description provided by the author
TODO: should stream be io.ReadCloser? Who owns closing the attachment.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
connectionString should be ConnectionString or RavenConnectionString.
No description provided by the author
No description provided by the author
NewPutIndexesCommand returns new PutIndexesCommand.
NewPutIndexesOperation returns new PutIndexesOperation.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewRangeFacet returns new RangeFacet parent is optional (can be nil).
NewRangeValue creates a new RangeValue.
No description provided by the author
No description provided by the author
No description provided by the author
NewRequestExecutor creates a new executor.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewServerNode creates a new ServerNode.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewSetIndexesPriorityCommand returns new SetIndexesPriorityCommand.
NewSetIndexesPriorityOperation returns new SetIndexesPriorityParameters.
NewSpatialBounds returns new SpatialBounds.
No description provided by the author
No description provided by the author
NewSpatialOptions returns new SpatialOptions with default values.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewStreamOperation returns new StreamOperation.
NewSubscriptionWorker returns new SubscriptionWorker.
NewSubscriptionWorkerOptions returns new SubscriptionWorkerOptions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewTimeoutError returns new TimeoutError.
No description provided by the author
No description provided by the author
NewUUID creates a new UUID.
No description provided by the author
No description provided by the author
ParseTime parses string time value returned by RavenDB server The value can't be parsed with a single string format.
Pluralize or singularize a word based on the passed in count.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RoundToServerTime rounds t to the same precision as round-tripping to the server and back.
ToPlural makes a pluralized version of a word.
ToSingular singularizes a word.
WithFiddler Setup proxy for fiddler.

# Constants

No description provided by the author
No description provided by the author
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
CommandNone = "NONE".
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
Note: this is enum in Java but those are serialized to json as strings so making them strings is better in Go.
ConcurrencyCheckAuto is automatic optimistic concurrency check depending on UseOptimisticConcurrency setting or provided Change Vector.
ConcurrencyCheckDisabled disables optimistic concurrency check even if UseOptimisticConcurrency is set.
ConcurrencyCheckForced forces optimistic concurrency check even if UseOptimisticConcurrency is not set.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TODO: make those into a string?.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Name of struct field that represents identity property.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TBD CUSTOM_SORT_FIELD_NAME = "__customSort";.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
about 4.78 meters at equator, should be good enough (see: http://unterbahn.com/2009/11/metric-dimensions-of-geohash-partitions-at-the-equator/).
about 4.78 meters at equator, should be good enough.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SubscriptionOpeningStrategyOpenIfFree: The client will successfully open a subscription only if there isn't any other currently connected client.
SubscriptionOpeningStrategyTakeOver: The connecting client will successfully open a subscription even if there is another active subscription's consumer.
SubscriptionOpeningStrategyWaitForFree: If the client currently cannot open the subscription because it is used by another client but it will wait for that client to complete and keep attempting to gain the subscription.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

if true, adds lots of logging to track bugs in request executor.
No description provided by the author
DefaultFacetOptions are default facet options.
HTTPClientPostProcessor allows to tweak http client after it has been created this allows replacing Transport with a custom transport that does logging, proxying or tweaks each http request.
LogSubscriptions allows to monitor read/writes made by SubscriptionWorker to a tcp connection.
if true, does verbose logging.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

AdvancedSessionExtensionBase implements common advanced session operations.
AdvancedSessionOperations exposes advanced session operations.
AfterSaveChangesEventArgs describes arguments for "after save changes" listener.
TODO: should this be exported?.
AllTopologyNodesDownError represents "all topology nodes are down" error.
AttachmentDetails represents details of an attachment.
AttachmentName represents infor about an attachment.
AttachmentResult represents an attachment.
AuthorizationError represents authorization error.
BadRequestError maps to server's 400 Bad Request response This is additional information sent by the server.
BadResponseError represents "bad response" error.
BatchCommand represents batch command.
BatchOperation represents a batch operation.
BatchOptions describes options for batch operations.
BeforeDeleteEventArgs describes arguments for "before delete" listener.
BeforeQueryEventArgs describes arguments for "before query" event.
BeforeStoreEventArgs describe arguments for "before store" listener.
BulkInsertAbortedError represents "bulk insert aborted" error.
BulkInsertCommand describes build insert command.
BulkInsertOperation represents bulk insert operation.
No description provided by the author
No description provided by the author
CertificateNameMismatchError is returned when subscription is in use.
No description provided by the author
CircleCriteria describes circle criteria.
ClientConfiguration represents client configuration.
ClientVersionMismatchError is returned when subscription is in use.
ClusterTopology is a part of ClusterTopologyResponse.
No description provided by the author
CmpXchg represents data for cmp xchg method.
CollectionStatistics describes collection statistics.
No description provided by the author
CommandData describes common data for commands.
No description provided by the author
CompactDatabaseCommand describes "compact database" command.
CompactDatabaseOperation describes "compact database" operation.
CompactSettings is an argument to CompactDatabaseOperation.
CompareExchangeResult describes result of compare exchange.
No description provided by the author
CompareExchangeValue represents value for compare exchange.
No description provided by the author
ConcurrencyError represents concurrency error.
No description provided by the author
No description provided by the author
ConfigureRevisionsCommand represents configure revisions command.
ConfigureRevisionsOperation represents configure revisions operation.
ConfigureRevisionsOperationResult represents result of configure revisions operation.
Conflict represents conflict.
ConflictError maps to server's 409 Conflict response.
ConflictSolver describes how to resolve conflicts.
ConnectionString represents connection string used as argument to PutConnectionStringCommand.
CreateDatabaseCommand represents "create database" command.
CreateDatabaseOperation represents "create database" operation.
CreateSampleDataCommand represents command for creating sample data.
CreateSampleDataOperation represents operation to create sample data.
CreateSubscriptionCommand represents "create subscription" command.
CreateSubscriptionResult represents result for "create subscription" command.
No description provided by the author
DatabaseChanges notifies about changes to a database.
No description provided by the author
No description provided by the author
DatabaseDoesNotExistError represents "database not not exist" error.
No description provided by the author
No description provided by the author
No description provided by the author
DatabasePutResult describes server response for e.g.
DatabaseRecord represents database record.
DatabaseRecordWithEtag represents database record with etag.
DatabaseStatistics describes a result of GetStatisticsCommand.
DatabaseTopology describes a topology of the database.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DeleteCommandData represents data for delete command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DeleteDatabaseResult represents result of Delete Database command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DeleteSubscriptionCommand describes "delete subscription" command.
No description provided by the author
No description provided by the author
DocumentChange describes a change to the document.
DocumentConflictError represents document conflict error from the server.
DocumentConventions describes document conventions.
No description provided by the author
DocumentQuery describes a query.
DocumentQueryCustomization allows customizing query.
DocumentQueryOptions describes options for creating a query.
DocumentsChanges describes a change in a document.
DocumentSession is a Unit of Work for accessing RavenDB server.
No description provided by the author
No description provided by the author
DocumentSessionRevisions represents revisions operations.
DocumentStore represents a database.
DocumentSubscriptions allows subscribing to changes in the store.
DropSubscriptionConnectionCommand describes "drop subscription" command.
No description provided by the author
No description provided by the author
No description provided by the author
ExpirationConfiguration.
No description provided by the author
No description provided by the author
No description provided by the author
ExternalReplication describes external replication.
Facet describes a search facet.
No description provided by the author
No description provided by the author
FacetOptions describes options for facet.
FacetResults represents results of faceted search.
FacetSetup describes new facet setup.
No description provided by the author
GenericQueryResult represents query results.
GenericRangeFacet represents generic range facet.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetConflictsResult represents result of "get conflict" command.
No description provided by the author
No description provided by the author
GetDatabaseNamesResult describes response of GetDatabaseNames command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetDocumentsResult is a result of GetDocument command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetNextOperationIDCommand represents command for getting next id from the server.
No description provided by the author
No description provided by the author
GetResponse represents result of get request.
GetRevisionOperation represents "get revisions" operation.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetSubscriptionsCommand describes "delete subscription" command.
GetSubscriptionsResult represents result of "get subscriptions".
GetSubscriptionStateCommand describes "get subscription state" command.
GetTcpInfoCommand describes "get tcp info" command.
GetTermsCommand represents "get terms" command.
GetTermsOperation represents "get terms" operation.
GroupBy represents arguments to "group by" query.
GroupByDocumentQuery represents a "group by" query.
GroupByField represents a field by which to group in a query.
No description provided by the author
No description provided by the author
HeadDocumentCommand describes "head document" command.
HiLoIDGenerator generates document ids server side.
HiLoResult is a result of HiLoResult command.
HiLoReturnCommand represents "hi lo return" command.
IllegalArgumentError represents illegal argument error.
IllegalStateError represents illegal state error.
No description provided by the author
IndexChange describes a change to the index.
No description provided by the author
No description provided by the author
IndexCreationTask is for creating IndexDefinition.
No description provided by the author
No description provided by the author
No description provided by the author
IndexDoesNotExistError represents "index doesn't exist" error.
IndexErrors describes index errors.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IndexingError describes indexing error message from the server.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
InMemoryDocumentSessionOperations represents database operations queued in memory.
No description provided by the author
JavaScriptArray builds arguments for patch operation on array fields.
No description provided by the author
JSONArrayResult describes server's JSON response to batch command.
KillOperationCommand represents "kill operation" command.
Lazy represents a lazy operation.
LazyAggregationQueryOperation represents lazy aggregation query operation.
LazyLoadOperation represents lazy load operation.
LazyMultiLoaderWithInclude is for lazily loading one or more objects with includes.
LazyQueryOperation describes server operation for lazy queries.
LazySessionOperations describes API for lazy operations.
LazyStartsWithOperation represents lazy starts with operation.
No description provided by the author
LeaderStamp describes leader stamp.
No description provided by the author
LoadOperation represents a load operation.
No description provided by the author
No description provided by the author
MetadataAsDictionary describes metadata for a document.
No description provided by the author
ModifyOngoingTaskResult represents a raven server command for modyfing task result.
No description provided by the author
No description provided by the author
No description provided by the author
MoreLikeThisQueryResult describes result of "more like this" operation.
No description provided by the author
No description provided by the author
MoreLikeThisUsingDocument represents more like this with a document.
No description provided by the author
MultiDatabaseHiLoIDGenerator manages per-database HiLoKeyGenerotr.
MultiGetCommand represents multi get command.
MultiGetOperation represents multi-get operation.
No description provided by the author
MultiTypeHiLoIDGenerator manages per-type HiLoKeyGenerator.
NextHiLoCommand represents a hi-lo database command.
No description provided by the author
NodeID describes a node.
No description provided by the author
NodeSelector describes node selector.
No description provided by the author
NodeStatus represents status of server node.
No description provided by the author
NonUniqueObjectError represents non unique object error.
NotImplementedError represents not implemented error.
Operation describes async operation being executed on the server.
OperationCancelledError represents "operation cancelled" error.
OperationExceptionResult represents an exception information from the server.
No description provided by the author
OperationIDResult is a result of commands like CompactDatabaseCommand.
OperationStatusChange describes a change to the operation status.
No description provided by the author
No description provided by the author
PatchCommand represents patch command.
No description provided by the author
PatchOperation represents patch operation.
PatchOperationPayload represents payload of patch operation Note: in Java it's Payload nested in PatchOperation.
PatchOperationResult represents result of patch operation Note: in Java it's Result nested in PatchOperation.
PatchRequest represents patch request.
PatchResult describes server results of patch command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PutCommandDataWithJSON represents data for put command with json.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PutConnectionStringResult describes result of "put connection" command.
No description provided by the author
PutIndexesCommand represents put indexes command.
PutIndexesOperation represents put indexes operation.
PutIndexesResponse represents server's response to PutIndexesCommand.
PutIndexResult represents result of put index command.
PutResult describes result of PutDocumentCommand.
No description provided by the author
QueryData represents.
QueryOperationOptions represents options for query operation.
QueryResults represents results of a query.
TODO: is time.Time here our *Time? TODO: needs json annotations?.
No description provided by the author
No description provided by the author
RangeBuilder helps build a string query for range requests.
RangeFacet describes range facet.
RangeValue represents an inclusive integer range min to max.
No description provided by the author
RavenConnectionString represents connection string for raven.
RavenError represents generic raven error all exceptions that in Java extend RavenException should contain this error.
No description provided by the author
No description provided by the author
ReplicationNode describes replication node.
No description provided by the author
RequestExecutor describes executor of HTTP requests.
No description provided by the author
No description provided by the author
ResponseTimeInformation describes timing information of server requests.
ResponseTimeItem represents a duration for executing a given url.
No description provided by the author
Revision describes a revision.
RevisionsCollectionConfiguration describes configuration for revisions collection.
RevisionsConfiguration describes revisions configuration.
No description provided by the author
No description provided by the author
RuntimeError represents generic runtime error.
ScriptResolver describes script resolver.
No description provided by the author
No description provided by the author
Semaphore is a Go implementation of Java's Semaphore.
No description provided by the author
ServerNode describes a single server node.
No description provided by the author
SessionCreatedEventArgs represents session created event args.
SessionInfo describes a session.
SessionOptions describes session options.
No description provided by the author
No description provided by the author
Note: in Java it's Parameters class nested in SetIndexesLockOperation Parameters is already taken.
SetIndexesPriorityCommand represents command to set indexes priority.
SetIndexesPriorityOperation represents operation for setting indexes priority.
SetIndexesPriorityParameters represents arrgument for SetIndexPriorityCommand Note: in Java it's Parameters class nested in SetIndexesPriorityOperation "Parameters" name is already taken.
Size describes size of entity on disk.
SpatialBounds describes bounds of a region.
No description provided by the author
No description provided by the author
SpatialOptions describes spatial options.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StartsWithArgs contains arguments for functions that return documents matching one or more options.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StreamIterator represents iterator of stream query.
StreamOperation represents a streaming operation.
No description provided by the author
StreamResult represents result of stream iterator.
No description provided by the author
SubscriberErrorError represents error about subscriber error Note: name is unfortunate but it corresponds to Java's SubscriberErrorException.
SubscriptionBatch describes a bunch of results for subscription.
SubscriptionBatchItem describes a single result from subscription.
SubscriptionChangeVectorUpdateConcurrencyError represents an error about subscription change vector update concurrency.
SubscriptionClosedError is returned when subscription is closed.
SubscriptionConnectionClientMessage describes a subscription connection message.
SubscriptionCreationOptions describes options for creating a subscription.
SubscriptionDoesNotBelongToNodeError is returned when subscription does not belong to node.
SubscriptionDoesNotExistError is returned when subscription doesn't exist.
a base type for subscription-related errors.
SubscriptionInUseError is returned when subscription is in use.
SubscriptionInvalidStateError is returned when subscription is in invalid state.
SubscriptionState describes state of subscription.
SubscriptionStateWithNodeDetails describes subscription state with node details.
SubscriptionTryout describes subscription tryout.
SubscriptionWorker describes subscription worker.
SubscriptionWorkerOptions describes options for subscription worker.
SuggestionsBuilder helps to build argument to SuggestUsing.
No description provided by the author
SuggestionDocumentQuery represents "suggestion" query.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TcpConnectionInfo describes tpc connection.
TermsQueryResult represents results of terms query.
TimeoutError represents timeout error.
Topology describes server nodes.
No description provided by the author
UnsupportedOperationError represents unsupported operation error.
No description provided by the author
No description provided by the author
UUID represents a random 16-byte number.
No description provided by the author
No description provided by the author

# Interfaces

DynamicSpatialField is an interface for implementing name of the field to be queried.
No description provided by the author
No description provided by the author
ICommandData represents command data.
No description provided by the author
No description provided by the author
ILazyOperation defines methods required to implement lazy operation.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RavenCommand defines interface for server commands.
No description provided by the author
for documentation purposes only TODO: could be simplified.

# Type aliases

Note: AggregationDocumentQuery is fused into AggregationQueryBase because in Java AggregationQueryBase calls functions implemented in AggregationDocumentQuery and that doesn't translate to Go's embedding.
TODO: make a unique wrapper type.
No description provided by the author
No description provided by the author
ChangeType describes a type of a change in a document.
Note: for simplicity ClusterRequestExecutor logic is implemented in RequestExecutor because Go doesn't support inheritance.
using type alias for easy json serialization.
No description provided by the author
ConcurrencyCheckMode describes concurrency check.
TODO: only used in ConnectionString which is unused.
No description provided by the author
No description provided by the author
No description provided by the author
Duration is an alias for time.Duration that serializes to JSON in format compatible with ravendb server.
No description provided by the author
FacetTermSortMode describes sort mode for a facet.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TODO: desugar.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
For documentation/porting only.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ReadBalanceBehavior defines the type of read balancing.
TODO: write a unique wrapper type.
No description provided by the author
SpatialFieldType describe spatial field.
No description provided by the author
SpatialSearchStrategy represents spatial search strategy.
SpatialUnits describes units used for spatial queries.
No description provided by the author
SubscriptionClientMessageType describes type of subscription client message.
SubscriptionOpeningStrategy describes opening strategy for subscriptions.
No description provided by the author
Time is an alias for time.Time that serializes/deserializes in ways compatible with Ravendb server.
No description provided by the author