8000 [Proposal] - New Building Block: DocumentStore · Issue #5146 · dapr/dapr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Proposal] - New Building Block: DocumentStore #5146
Open
@berndverst

Description

@berndverst

Proposal - New Building Block: DocumentStore

Background:

As one of the maintainers of components-contrib it is very apparent that some state stores and their respective use cases are unlike others. MongoDB, RethinkDB and some uses of PostgreSQL are some examples here which store (in the case of PostgreSQL this is optional) data very differently from other state store components.

A DocumentStore allows accessing individual nested properties of a document. These can also be queried. Importantly, data types are retained on the nested properties in many document stores.

Interface

All DocumentStore components should have the following:

  • Get Document (by key)
  • Multi Get Documents (by key)
  • Create Document
  • Replace Document
  • Delete Document
  • Multi Delete Documents
  • Query (Find) Documents Query API support (native support of searching within documents)
  • Update Document -- a HTTP Patch operation which can be used to replace nested document attributes. This should support a query filter since many document stores allow updating multiple documents matching a query.

The Query and Get operations should support filtering (projecting) of attributes/properties returned. This is done natively by the DocumentStore where supported and to be done by the component implementation if this is not natively supported.

Note: There is no intention to be compatible with data written / stored via state stores as this can lead to inefficient and complex design / implementation decisions as well as anti-patterns. However, the DocumentStore should be able to read data created by non-Dapr sources.

Content Type support requirements

  • BSON (application/bson): This is the default content-type that all document stores must support as it contains data type information.
  • JSON (application/json): This should be supported, but its use generally discouraged as it is a lossy format which for example cannot distinguish between integer and float data types.

As a consequence of this of this proposal:

  • The Query API (Alpha) should eventually be deprecated from State Store (it can coexist until DocumentStores are stable).
  • MongoDB, RethinkDB, PostgreSQL, AWS DocumentDB, Azure CosmosDB, and possibly others should also be made available as DocumentStores.
  • SDKs need to implement support for this new building block and support BSON encoding/decoding.

Potential REST API (request parameters and details not included here).

Create document:
POST http://localhost:<daprPort>/v1.0/document/<storename>/<collection>

Replace Document:
PUT http://localhost:<daprPort>/v1.0/document/<storename>/<collection>/<docid>

Update Document:
PATCH http://localhost:<daprPort>/v1.0/document/<storename>/<collection>/<docid>

Get Document by ID:
GET http://localhost:<daprPort>/v1.0/document/<storename>/<collection>/<docid>

Get Multiple Documents by ID:
GET http://localhost:<daprPort>/v1.0/document/<storename>/<collection>

Delete Document by ID:
DELETE http://localhost:<daprPort>/v1.0/document/<storename>/<collection>/<docid>

Delete Multiple Documents by ID:
DELETE http://localhost:<daprPort>/v1.0/document/<storename>/<collection>

Query Documents:
GET http://localhost:<daprPort>/v1.0/document/<storename>/<collection>/query

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0