https://github.com/tbdsux/detanim
Deta SDK for NimLang
https://github.com/tbdsux/detanim
deta detabase detanim
Last synced: 10 months ago
JSON representation
Deta SDK for NimLang
- Host: GitHub
- URL: https://github.com/tbdsux/detanim
- Owner: tbdsux
- License: isc
- Archived: true
- Created: 2021-08-31T00:11:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-22T02:10:53.000Z (about 3 years ago)
- Last Synced: 2024-11-02T16:06:43.643Z (over 1 year ago)
- Topics: deta, detabase, detanim
- Language: Nim
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deta - detanim - Deta SDK for NimLang. (SDK's / Nim SDK)
README
# detanim
Deta SDK for NimLang
## Install
```sh
nimble install https://github.com/TheBoringDude/detanim.git
```
## Usage
```nim
import detanim, os, json
let
r = Deta(getEnv("API_KEY"))
base = r.Base("sample")
echo "putting new data for key `hello`"
let x = base.put(@[%*{"key": "123", "hello": "world"}])
echo $x
echo "getting data of key `hello`"
let (data, _) = base.get("123")
echo $data
```
- Async support
```nim
import detanim, json, asyncdispatch
let
r = newDeta()
base = r.newAsyncBase("sample")
type
Data = object
key: string
hello: string
number: int
boolean: bool
proc main() {.async.} =
echo "putting new data with key: [123]"
let key = await base.put(%*{"hello": "world",
"number": 99, "boolean": false}, "123")
echo "key: ", key
echo "getting data with key: [123]"
let (resp, exists) = await base.get("123")
if not exists:
quit("Key does not exist!")
let data = to(resp, Data)
echo(data.hello)
waitFor main()
```
## Currently Implemented Functions
Functions are not fully tested, please file issues if they are not working as expected.
- **Base**
- get
- put
- putMany
- insert
- delete
- query
- update
- **Drive**
- put - only 10Mb put files (chunk upload not yet supported)
- download - `get`
- list
- delete
##
**© 2021 | [tbdsux](https://tbdsux.github.io/)**