Skip to content

Unofficial PocketBase API Client for R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

telostat/rocketbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rocketbase - Unofficial PocketBase API Client for R

GitHub release (latest by date) github last commit GitHub contributors

rocketbase is an unofficial PocketBase API client for R.

Installation

rocketbase is currently not on CRAN. The easiest way to install it is using devtools.

For the latest development snapshot:

devtools::install_github("telostat/rocketbase", upgrade="ask")

For the latest version (X.Y.Z, following semantic versioning):

devtools::install_github("telostat/rocketbase", ref="X.Y.Z", upgrade="ask")

Development

Enter the Nix shell and launch PocketBase:

nix-shell
pocketbase-serve

Create an admin user account on PocketBase. Now, on another console session, enter Nix shell:

nix-shell

Launch R:

R

Here is a sample session:

devtools::load_all(".")
rb <- rocketbase::RocketBase$new("http://localhost:8090", identity = "[email protected]", password = "hebelehubele")
response <- rb$bare$get("/api/collections/users/records")
stopifnot(response$status_code == 200)
my_data <- jsonlite::fromJSON(response$parse(encoding = "UTF-8"))
print(my_data)

table <- list(
    name = "observations",
    type = "base",
    system = FALSE,
    schema = list(
        list(
            "name" = "key",
            "type" = "text",
            "system" = FALSE,
            "required" = TRUE,
            "unique" = TRUE,
            "nullable" = FALSE
        ),
        list(
            "name" = "value",
            "type" = "text",
            "system" = FALSE,
            "required" = FALSE,
            "unique" = FALSE,
            "nullable" = TRUE
        )
    )
)
response <- rb$bare$post("/api/collections", encode = "json", body=table)
stopifnot(response$status_code == 200)

response <- rb$bare$get("/api/collections/observations/records")
stopifnot(response$status_code == 200)
my_data <- jsonlite::fromJSON(response$parse(encoding = "UTF-8"))
print(my_data)

response <- rb$bare$post("/api/collections/observations/records", encode = "json", body=list(
    key = "key1",
    value = "value1"
))
stopifnot(response$status_code == 200)

response <- rb$bare$post("/api/collections/observations/records", encode = "json", body=list(
    key = "key2",
    value = "value2"
))
stopifnot(response$status_code == 200)

response <- rb$bare$get("/api/collections/observations/records")
stopifnot(response$status_code == 200)
my_data <- jsonlite::fromJSON(response$parse(encoding = "UTF-8"))
print(my_data)

Releasing

Make sure that your main branch is up to date:

git checkout main
git pull

Then, run the release script with new version information:

./release.sh -n <X.Y.Z>

License

This work is licensed under MIT license. See LICENSE.

About

Unofficial PocketBase API Client for R

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks