Skip to content

Commit 2896280

Browse files
committed
add examples
1 parent f57500e commit 2896280

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pocketbasearduino.ino
44
pb_data
55
pb_migrations
66
pocketbase.exe
7-
examples
87
CHANGELOG.md
98
LICENSE.md
109
pocketbase_0.20.5_windows_amd64.zip

examples/example.ino

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include "PocketBaseArduino.h"
2+
3+
// ESP8266
4+
#include <ESP8266WiFi.h>
5+
#include <ESP8266HTTPClient.h>
6+
7+
// FOR ESP32
8+
// #include <HTTPClient.h>
9+
// #include <WiFi.h>
10+
// #include <WiFiClientSecure.h>
11+
12+
// HTTPS REQUESTS
13+
#include <BearSSLHelpers.h>
14+
15+
const char *ssid = "YOUR_SSID";
16+
const char *password = "YOUR_PASSWORD";
17+
18+
// Initializing the Pocketbase instance
19+
PocketbaseArduino pb("YOUR_POCKETBASE_BASE_URL");
20+
String record;
21+
22+
void setup()
23+
{
24+
Serial.begin(115200);
25+
WiFi.begin(ssid, password);
26+
27+
while (WiFi.status() != WL_CONNECTED)
28+
{
29+
delay(1000);
30+
Serial.println("Connecting to WiFi...");
31+
}
32+
33+
// Example usage of getOne() function
34+
// getOne("record_id", "expand", "fields"),
35+
// if expand or fields are empty place nullptr
36+
record = pb.collection("collection_name").getOne("record_id", "expand", "fields");
37+
38+
// Example usage of getList() function
39+
// getList("page", "perPage", "sort", "filter", "skipTotal", "expand", "fields"),
40+
// if expand or fields are empty place nullptr
41+
record = pb.collection("collection_name").getList("page", "perPage", "sort", "filter", "skipTotal", "expand", "fields");
42+
43+
// Example usage of deleteRecord function
44+
// deleteRecord("record_id");
45+
record = pb.collection("collection_name").deleteRecord("record_id");
46+
47+
// printing data
48+
Serial.println(record);
49+
}
50+
51+
void loop()
52+
{
53+
// Fetches and prints data from the 'notes' collection every 5 seconds
54+
record = pb.collection("collection_name").getList("page", "perPage", "sort", "filter", "skipTotal", "expand", "fields");
55+
Serial.println("Data from 'notes' collection:\n" + record);
56+
delay(5000);
57+
}

0 commit comments

Comments
 (0)