package
0.6.1
Repository: https://github.com/btnguyen2k/godal.git
Documentation: pkg.go.dev

# README

godal/cosmosdbsql

PkgGoDev codecov

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 implements IGenericDao.GdaoCreateFilter(string, IGenericBo) FilterOpt.
  • Configure either {collection-name:path-to-fetch-partition_key-value-from-genericbo} via GenericDaoCosmosdb.CosmosSetPkGboMapPath or {collection-name:path-to-fetch-partition_key-value-from-dbrow} via GenericDaoCosmosdb.CosmosSetPkRowMapPath.
  • Optionally, configure {collection-name:path-to-fetch-id-value-from-genericbo} via GenericDaoCosmosdb.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} via GenericDaoCosmosdb.CosmosSetPkGboMapPath or {collection-name:path-to-fetch-partition_key-value-from-dbrow} via GenericDaoCosmosdb.CosmosSetPkRowMapPath.

Examples: see examples and examples_sta.

This package explicitly uses github.com/btnguyen2k/gocosmos as the SQL driver for Azure Cosmos DB.