https://github.com/mkloubert/appwrite-sdk-js
An (unofficial) enhancement for official SDK of Appwrite.
https://github.com/mkloubert/appwrite-sdk-js
appwrite appwrite-database sdk sdk-nodejs typescript typescript-library
Last synced: 10 months ago
JSON representation
An (unofficial) enhancement for official SDK of Appwrite.
- Host: GitHub
- URL: https://github.com/mkloubert/appwrite-sdk-js
- Owner: mkloubert
- License: mit
- Created: 2025-03-18T09:49:12.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-18T16:44:12.000Z (10 months ago)
- Last Synced: 2025-03-18T17:37:27.299Z (10 months ago)
- Topics: appwrite, appwrite-database, sdk, sdk-nodejs, typescript, typescript-library
- Language: TypeScript
- Homepage: https://mkloubert.github.io/appwrite-sdk-js/
- Size: 199 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# @marcelkloubert/appwrite-sdk
> An (unofficial) enhancement for [official SDK of Appwrite](https://appwrite.io/docs/quick-starts/node) which runs on [Node.js 18+](https://nodejs.org/en/blog/release/v18.0.0/) or later.
## Install
Execute the following command from your project folder, where your package.json file is stored:
```bash
npm i @marcelkloubert/appwrite-sdk
```
## Usage
```typescript
import { Query } from "node-appwrite";
import { AppwriteProject } from "@marcelkloubert/appwrite-sdk";
interface BarCollection {
buzz: number;
}
// set environment variables `APPWRITE_API_KEY` and `APPWRITE_PROJECT_ID`
// with correct values
const project = new AppwriteProject();
// initialize project and make it available
// as a singleton instance if possible
await project.init({ withDatabase: true });
for (const database of project.databases) {
console.log("Database:", database.name);
// `database` is an iterator of collections
for (const collection of database) {
console.log("\tCollection:", collection.name);
// `collection` is an iterator of attributes
for (const attribute of collection) {
console.log("\tAttribute:", attribute.name);
}
}
}
// get existing database `foo`
const foo = project.databases.getDatabase("foo");
// get existing collection `bar` inside `foo`
const bar = foo.getCollection("bar").wrap();
// insert a new document
const newDoc = await bar.insertOne({ buzz: 42 });
// update an existing document
const updatedDoc = await bar.updateOne(newDoc, { buzz: 666 });
// remove a document
await bar.deleteOne(updatedDoc);
// query multiple documents
const asyncCursor = bar.query({
queries: [Query.greaterThan("$createdAt", new Date().toISOString())],
});
for await (const document of asyncCursor) {
console.log("Document:", document.$id);
}
// query a single document
const maybeExistingDoc = await bar.queryOne({
queries: [Query.equal("buzz", 667)],
});
if (maybeExistingDoc) {
console.log("Document with buzz=667 exists as:", maybeExistingDoc.$id);
} else {
console.log("Document with buzz=667 does not exist");
}
```
## Currently supported
The project is currently under heavy development.
Currently the following features running have a "quite stable" beta status:
- [x] [Databases](https://appwrite.io/docs/references/cloud/client-web/databases)
- [ ] [Account](https://appwrite.io/docs/references/cloud/client-web/account)
- [ ] [Avatars](https://appwrite.io/docs/references/cloud/client-web/avatars)
- [ ] [Functions](https://appwrite.io/docs/references/cloud/client-web/functions)
- [ ] [Localization](https://appwrite.io/docs/references/cloud/client-web/locale)
- [ ] [Messaging](https://appwrite.io/docs/references/cloud/client-web/messaging)
- [ ] [Storage](https://appwrite.io/docs/references/cloud/client-web/storage)
- [ ] [Teams](https://appwrite.io/docs/references/cloud/client-web/teams)
- [ ] [Users](https://appwrite.io/docs/references/cloud/client-web/users)
## Documentation
The API documentation can be found [here](https://mkloubert.github.io/appwrite-sdk-js/).
## License
MIT © [Marcel Joachim Kloubert](https://github.com/mkloubert)
## Support and contribute
[Contribution guidelines](./CONTRIBUTE.md)