# README
godal/cosmosdbsql
Generic Azure Cosmos DB DAO implementation using database/sql
interface.
Guideline
General
- DAOs must implement
IGenericDao.GdaoCreateFilter(string, IGenericBo) FilterOpt
.
Use GenericDaoCosmosdb
(and godal.IGenericBo
) directly
- Define a DAO struct that extends
GenericDaoCosmosdb
and implementsIGenericDao.GdaoCreateFilter(string, IGenericBo) FilterOpt
. - Configure either
{collection-name:path-to-fetch-partition_key-value-from-genericbo}
viaGenericDaoCosmosdb.CosmosSetPkGboMapPath
or{collection-name:path-to-fetch-partition_key-value-from-dbrow}
viaGenericDaoCosmosdb.CosmosSetPkRowMapPath
. - Optionally, configure
{collection-name:path-to-fetch-id-value-from-genericbo}
viaGenericDaoCosmosdb.CosmosSetIdGboMapPath
. - Optionally, create a helper function to create DAO instances.
Implement custom database/sql
business DAOs and BOs
- Define and implement the business DAO (Note: DAOs must implement
IGenericDao.GdaoCreateFilter(string, IGenericBo) FilterOpt
). - Define functions to transform
godal.IGenericBo
to business BO and vice versa. - Optionally, create a helper function to create DAO instances.
Partition key (PK) is crucial to CosmosDB. PK value is needed in almost all document related operations. Hence, it's important to be able to extract PK value from BO. If using or extending
GenericDaoCosmosdb
, configure either{collection-name:path-to-fetch-partition_key-value-from-genericbo}
viaGenericDaoCosmosdb.CosmosSetPkGboMapPath
or{collection-name:path-to-fetch-partition_key-value-from-dbrow}
viaGenericDaoCosmosdb.CosmosSetPkRowMapPath
.
Examples: see examples and examples_sta.
This package explicitly uses github.com/btnguyen2k/gocosmos as the SQL driver for Azure Cosmos DB.