deta-swift
Deta-Swift is the unofficial Deta SDK for Swift.
:warning: Still under development.
Installation
Simply add .package(url: "https://github.com/pkrll/deta-swift.git", from: "1.0.0")
to your dependencies in Package.swift
.
Usage
To start using Deta, you need to first retrieve your project key. Initialize the Deta object with your project key, and the name of your Deta base:
The Deta SDK for Swift supports all of Deta's HTTP API endpoints currently available.
:warning: Warning :warning:
Remember that your project key is a secret. Anyone with the key can access and modify your database. This SDK is not meant to be used client side, as it requires the API key to be sent over HTTPs and therefore visible for everyone. Do not commit this key to a public repository.
Put Item
The put
method allows for adding multiple items to the Deta base in a single request. Your models must conform to the Fetchable
protocol.
For more information, please see the documentation for Put Item on Deta Docs.
Get Item
The get
method retrieves a single item from the Deta base. This method requires a specific model type specified when retrieving. The return value must conform to your model, otherwise an error is returned.
If the item does not exist, an error will be returned.
For more information, please see the documentation for Get Item on Deta Docs.
Delete Item
The delete
method deletes an item from the Deta base. Regardless of whether the item exists or not, a successful response will be returned.
For more information, please see the documentation for Delete Item on Deta Docs.
Insert Item
The insert
method inserts a single item into the Deta Base. If an item with the same key already exists, an error will be returned.
For more information, please see the documentation for Insert Item on Deta Docs.
Update Item
The update
method updates an item based on a specified set of rules. If the key does not exist, an error is returned.
The Update.Request
payload may have the following fields:
For more information, please see the documentation for Update Item on Deta Docs.
Fetch Item
The fetch
method retrieves items that matches the specified query. A query is a list of dictionaries with a string key and AnyEncodable values. For more information on how to build a query, please consult the (Deta docs)[https://docs.deta.sh/docs/base/sdk/#queries].
For more information, please see the documentation for Query Item on Deta Docs.