Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

tbdsux/detanim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

detanim

Deta SDK for NimLang

Install

nimble install https://github.com/TheBoringDude/detanim.git

Usage

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

    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

About

Deta SDK for NimLang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages