dendrite/internal/cosmosdbapi/documentoperations.go
alexfca 5d68daef80
Implement Cosmos DB for the RoomServer Service (#5)
* - Implement Cosmos for the devices_table
- Use the ConnectionString in the YAML to include the Tenant
- Revert all other non implemented tables back to use SQLLite3

* - Change the Config to use "test.criticicalarc.com" Container
- Add generic function GetDocumentOrNil to standardize GetDocument
- Add func to return CrossPartition queries for Aggregates
- Add func GetNextSequence() as generic seq generator for AutoIncrement
- Add cosmosdbutil.ErrNoRows to return (emulate) sql.ErrNoRows
- Add a "fake" ExclusiveWriterFake
- Add standard "getXX", "setXX" and "queryXX" to all TABLE class files
- Add specific Table SEQ for the Events table
- Add specific Table SEQ for the Rooms table
- Add specific Table SEQ for the StateSnapshot table
2021-05-20 14:42:33 +10:00

55 lines
1.3 KiB
Go

package cosmosdbapi
import (
cosmosapi "github.com/vippsas/go-cosmosdb/cosmosapi"
)
func GetCreateDocumentOptions(pk string) cosmosapi.CreateDocumentOptions {
return cosmosapi.CreateDocumentOptions{
IsUpsert: false,
PartitionKeyValue: pk,
}
}
func GetUpsertDocumentOptions(pk string) cosmosapi.CreateDocumentOptions {
return cosmosapi.CreateDocumentOptions{
IsUpsert: true,
PartitionKeyValue: pk,
}
}
func GetQueryDocumentsOptions(pk string) cosmosapi.QueryDocumentsOptions {
return cosmosapi.QueryDocumentsOptions{
PartitionKeyValue: pk,
IsQuery: true,
ContentType: cosmosapi.QUERY_CONTENT_TYPE,
}
}
func GetQueryAllPartitionsDocumentsOptions() cosmosapi.QueryDocumentsOptions {
return cosmosapi.QueryDocumentsOptions{
IsQuery: true,
EnableCrossPartition: true,
ContentType: cosmosapi.QUERY_CONTENT_TYPE,
}
}
func GetGetDocumentOptions(pk string) cosmosapi.GetDocumentOptions {
return cosmosapi.GetDocumentOptions{
PartitionKeyValue: pk,
}
}
func GetReplaceDocumentOptions(pk string, etag string) cosmosapi.ReplaceDocumentOptions {
return cosmosapi.ReplaceDocumentOptions{
PartitionKeyValue: pk,
IfMatch: etag,
}
}
func GetDeleteDocumentOptions(pk string) cosmosapi.DeleteDocumentOptions {
return cosmosapi.DeleteDocumentOptions{
PartitionKeyValue: pk,
}
}