PocketBaseCore 1.0.0
See the version list below for details.
dotnet add package PocketBaseCore --version 1.0.0
NuGet\Install-Package PocketBaseCore -Version 1.0.0
<PackageReference Include="PocketBaseCore" Version="1.0.0" />
paket add PocketBaseCore --version 1.0.0
#r "nuget: PocketBaseCore, 1.0.0"
// Install PocketBaseCore as a Cake Addin #addin nuget:?package=PocketBaseCore&version=1.0.0 // Install PocketBaseCore as a Cake Tool #tool nuget:?package=PocketBaseCore&version=1.0.0
PocketBaseCore
A .NET Core and Standard 2.0 wrapper for the PocketBase API.
Installation
Install the package via NuGet:
dotnet add package PocketBaseCore --version 1.0.0
Usage
Authentication
Before making any requests, authenticate with the API:
var client = new PocketBaseClient("https://your-pocketbase-url");
var authResponse = await client.AuthenticateAsync("your-identity", "your-password");
Creating Records
To create a record using a custom POCO class:
var company = new Company
{
Name = "Acme Inc",
Website = "https://acme.com",
Sector = "Technology"
};
company = await client.CreateRecordAsync<Company>("company", company);
If you prefer not to use a custom POCO class, you can use JsonNode
instead:
var company = new JsonObject
{
["name"] = "Acme Inc",
["website"] = "https://acme.com",
["sector"] = "Technology"
};
company = await client.CreateRecordAsync<JsonNode>("company", company);
Updating a Record
To update a record:
var updateData = new Dictionary<string, object>
{
{ "name", "New Acme Inc" }
};
company = await client.UpdateRecordAsync<Company>("company", company.Id, updateData);
Alternatively, using JsonNode
:
var updateData = new JsonObject
{
["name"] = "New Acme Inc"
};
company = await client.UpdateRecordAsync<JsonNode>("company", company["id"].ToString(), updateData);
Retrieving a Record
To retrieve a record:
var retrievedCompany = await client.GetRecordAsync<Company>("company", company.Id);
Or with JsonNode
:
var retrievedCompany = await client.GetRecordAsync<JsonNode>("company", company["id"].ToString());
Working with Relationships
To create records with relationships:
// Create a company
var company = new Company
{
Name = "Acme Inc",
Website = "https://acme.com",
Sector = "Technology"
};
company = await client.CreateRecordAsync<Company>("company", company);
// Create an employee
var employee = new Employee
{
FullName = "John Doe",
Email = "[email protected]",
PhoneNumber = "1234567890",
Company = company.Id
};
employee = await client.CreateRecordAsync<Employee>("employee", employee, expand: "company");
Or using JsonNode
for both:
// Create a company
var company = new JsonObject
{
["name"] = "Acme Inc",
["website"] = "https://acme.com",
["sector"] = "Technology"
};
company = await client.CreateRecordAsync<JsonNode>("company", company);
// Create an employee
var employee = new JsonObject
{
["fullName"] = "John Doe",
["email"] = "[email protected]",
["phoneNumber"] = "1234567890",
["company"] = company["id"].ToString()
};
employee = await client.CreateRecordAsync<JsonNode>("employee", employee, expand: "company");
Filtering and Sorting
To filter and sort a collection:
var companiesSorted = await client.GetRecordsAsync<Company>("company", fields: "id,name,sector", sort: "-name");
var companiesFiltered = await client.GetRecordsAsync<Company>("company", filter: "(name = 'Company 5')");
Or using JsonNode
:
var companiesSorted = await client.GetRecordsAsync<JsonNode>("company", fields: "id,name,sector", sort: "-name");
var companiesFiltered = await client.GetRecordsAsync<JsonNode>("company", filter: "(name = 'Company 5')");
Deleting Records
To delete records, use the following code:
// Delete a company
await client.DeleteRecordAsync("company", company.Id);
// Delete an employee
await client.DeleteRecordAsync("employee", employee.Id);
If using JsonNode
:
// Delete a company
await client.DeleteRecordAsync("company", company["id"].ToString());
// Delete an employee
await client.DeleteRecordAsync("employee", employee["id"].ToString());
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of PocketBaseCore.