1.2.6 • Published 4 years ago

react-native-azure-cosmos v1.2.6

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

react-native-azure-cosmos

This package provide query and insert against azure cosmos db

Install

npm i react-native-azure-cosmos --save

Usage

Import library

import { azurefetch, initAzureCosmos } from 'react-native-azure-cosmos/azurecosmos'

Init cosmos auth

class App extends React.Component {
  constructor(props) {
    super(props);
    initAzureCosmos(
    {
      masterKey:${YOUR COSMOS DB MASTER KEY},
      version: "2017-02-22",
      dbUri: ${YOUR COSMOS DB URL},
      dbname: ${YOUR COSMOS DB NAME},

    }
    ...
  }

Run a query

azure = async () => {
   const response = await azurefetch({
            dbname : "", //optional parameter if you want to quiry agiants another DB
            col: ${COL NAME},
            body: {
                "query": "SELECT c.id FROM ${COL NAME} c WHERE c.uid = @email",
                "parameters": [
                    { "name": "@email", "value": email }
                ]
            },
            type: 'Query',
            partitionKey: ${PARTITION VALUE}
        });

  }

INSERT new Docs

azure = async () => {
    const response = await azurefetch({
              col: ${COL NAME},
              body: {
                  "id": username,
                  "code": code,
                  "name": name,
                  "photoUri": photoURL,
              },
              type: 'Insert',
              partitionKey:  ${PARTITION VALUE}
          });

Exec SP

azure = async () => {
   const response = await azurefetch({
        spname: ${SP NAME},
        col: ${COL NAME},
        body: [id, { "photoUri": photoURL }],
        type: 'Sp',
        partitionKey: code
    });
1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago