Code Monkey home page Code Monkey logo

go-cosmosdb's Introduction

go-cosmosdb Build Status

go sdk for Azure Cosmos DB

Usage

  • instantiate a config struct. Set the keys, url and some other parameters.

  • call the constructor New(cfg config)

  • cosmosdb follows the hierarchy of Cosmos DB. This means that you can operate on the resource the current type represents. The database struct can work with resources that belong to a cosmos database, the Collection type can work with resources that belong to a collection.

  • doc interface{} may seem weird in some contexts, e.g. DeleteDocument, why not use a signature like DeleteDocument(ctx context.Context, id string). The reason is that there are several ways to address the document. Either by self link, with or without _etag or by the id. All on collections with or without a partition key.

    • use _self if possible
    • if _etag is present, use it
    • otherwise use id
    • if neither exists -> error

Examples

Create Document

type Document struct {
    id string
}

newDoc, err := coll.CreateDocument(context.Background(), doc)

#FAQ

go-cosmosdb's People

Contributors

aleksen avatar dagss avatar espensb avatar gmkvaal avatar hypirion avatar johnolebjerke avatar larstore avatar larstore-sonat avatar starsheriff avatar stianlagstad avatar thxmasj avatar tnicolaysen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.