https://github.com/blazerroadg/react-native-azure-cosmos
This package provide query and insert against azure cosmos db
https://github.com/blazerroadg/react-native-azure-cosmos
azure-cosmos-db cosmos react react-native reactjs
Last synced: 8 months ago
JSON representation
This package provide query and insert against azure cosmos db
- Host: GitHub
- URL: https://github.com/blazerroadg/react-native-azure-cosmos
- Owner: blazerroadg
- Created: 2020-06-20T14:15:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T00:15:41.000Z (almost 5 years ago)
- Last Synced: 2025-01-31T08:07:11.110Z (8 months ago)
- Topics: azure-cosmos-db, cosmos, react, react-native, reactjs
- Language: TypeScript
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```javascript
import { azurefetch, initAzureCosmos } from 'react-native-azure-cosmos/azurecosmos'
```Init cosmos auth
```javascript
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
```javascript
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
```javascript
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
```javascript
azure = async () => {
const response = await azurefetch({
spname: ${SP NAME},
col: ${COL NAME},
body: [id, { "photoUri": photoURL }],
type: 'Sp',
partitionKey: code
});
```