🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

appschema

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appschema - npm Package Compare versions

Comparing version
1.0.2
to
1.0.3
example/.env.example

Sorry, the diff of this file is not supported yet

+393
-4

@@ -13,5 +13,9 @@ {

"ajv": "^8.17.1",
"appschema": "^1.0.1",
"appschema": "^1.0.2",
"body-parser": "^1.20.3",
"dotenv": "^16.4.5",
"express": "^4.21.0"
},
"devDependencies": {
"nodemon": "^3.1.7"
}

@@ -48,6 +52,20 @@ },

},
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dev": true,
"license": "ISC",
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/appschema": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/appschema/-/appschema-1.0.1.tgz",
"integrity": "sha512-DJKl89zfqtAu6oHRUfO1SBVgrPzV7riK29CtvE0CjzFkY9IxpYXpkk5pyZ6Az/CjJnKbPBEtl7zGzMk6KC4avQ==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/appschema/-/appschema-1.0.2.tgz",
"integrity": "sha512-vnPMk1MgJngyoSv+67z7O/JJYQIuV6TPh7u2d4umrpw0Uw/HuKPjfVmHnL1a+OMnOy5w910zvZx5VcZzDE99UA==",
"license": "ISC",

@@ -71,2 +89,22 @@ "dependencies": {

},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true,
"license": "MIT"
},
"node_modules/binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/body-parser": {

@@ -96,2 +134,26 @@ "version": "1.20.3",

},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/braces": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"license": "MIT",
"dependencies": {
"fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/bytes": {

@@ -125,2 +187,34 @@ "version": "3.1.2",

},
"node_modules/chokidar": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
"dev": true,
"license": "MIT",
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true,
"license": "MIT"
},
"node_modules/content-disposition": {

@@ -207,2 +301,14 @@ "version": "0.5.4",

},
"node_modules/dotenv": {
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/ee-first": {

@@ -313,2 +419,15 @@ "version": "1.1.1",

},
"node_modules/fill-range": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"license": "MIT",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/finalhandler": {

@@ -350,2 +469,17 @@ "version": "1.3.1",

},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {

@@ -379,2 +513,15 @@ "version": "1.1.2",

},
"node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"license": "ISC",
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/gopd": {

@@ -392,2 +539,12 @@ "version": "1.0.1",

},
"node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/has-property-descriptors": {

@@ -469,2 +626,9 @@ "version": "1.0.2",

},
"node_modules/ignore-by-default": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
"integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
"dev": true,
"license": "ISC"
},
"node_modules/inherits": {

@@ -485,2 +649,48 @@ "version": "2.0.4",

},
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true,
"license": "MIT",
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-extglob": "^2.1.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/json-schema-traverse": {

@@ -552,2 +762,15 @@ "version": "1.0.0",

},
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/ms": {

@@ -568,2 +791,66 @@ "version": "2.0.0",

},
"node_modules/nodemon": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz",
"integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"chokidar": "^3.5.2",
"debug": "^4",
"ignore-by-default": "^1.0.1",
"minimatch": "^3.1.2",
"pstree.remy": "^1.1.8",
"semver": "^7.5.3",
"simple-update-notifier": "^2.0.0",
"supports-color": "^5.5.0",
"touch": "^3.1.0",
"undefsafe": "^2.0.5"
},
"bin": {
"nodemon": "bin/nodemon.js"
},
"engines": {
"node": ">=10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nodemon"
}
},
"node_modules/nodemon/node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/nodemon/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"dev": true,
"license": "MIT"
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {

@@ -608,2 +895,15 @@ "version": "1.13.2",

},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/proxy-addr": {

@@ -622,2 +922,9 @@ "version": "2.0.7",

},
"node_modules/pstree.remy": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
"dev": true,
"license": "MIT"
},
"node_modules/qs": {

@@ -662,2 +969,15 @@ "version": "6.13.0",

},
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dev": true,
"license": "MIT",
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/require-from-string": {

@@ -698,2 +1018,15 @@ "version": "2.0.2",

},
"node_modules/semver": {
"version": "7.6.3",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/send": {

@@ -794,2 +1127,15 @@ "version": "0.19.0",

},
"node_modules/simple-update-notifier": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
"integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
"dev": true,
"license": "MIT",
"dependencies": {
"semver": "^7.5.3"
},
"engines": {
"node": ">=10"
}
},
"node_modules/statuses": {

@@ -804,2 +1150,28 @@ "version": "2.0.1",

},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/toidentifier": {

@@ -814,2 +1186,12 @@ "version": "1.0.1",

},
"node_modules/touch": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
"integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
"dev": true,
"license": "ISC",
"bin": {
"nodetouch": "bin/nodetouch.js"
}
},
"node_modules/type-is": {

@@ -828,2 +1210,9 @@ "version": "1.6.18",

},
"node_modules/undefsafe": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
"integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
"dev": true,
"license": "MIT"
},
"node_modules/unpipe": {

@@ -830,0 +1219,0 @@ "version": "1.0.0",

@@ -15,6 +15,10 @@ {

"ajv": "^8.17.1",
"appschema": "^1.0.1",
"appschema": "^1.0.2",
"body-parser": "^1.20.3",
"dotenv": "^16.4.5",
"express": "^4.21.0"
},
"devDependencies": {
"nodemon": "^3.1.7"
}
}
+21
-9
const express = require('express');
const bodyParser = require('body-parser');
const { AppwriteConnection, Model, Repository } = require('appschema');
require('dotenv').config();
// Initialize Express app
const app = express();
const PORT = 3000;
const PORT = process.env.PORT;
app.use(bodyParser.json());
// Initialize Appwrite connection
AppwriteConnection.initialize('https://YOUR_APPWRITE_ENDPOINT', 'YOUR_PROJECT_ID', 'YOUR_API_KEY');
AppwriteConnection.initialize(process.env.APPWRITE_ENDPOINT, process.env.PROJECT_ID);
// Set up the Model and Repository for the user collection
const userModel = new Model('YOUR_COLLECTION_ID', 'YOUR_DATABASE_ID');
// model definition sample
const userSchema = {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'number' }
},
required: ['name', 'age'],
additionalProperties: false
};
// set Model and Repository for the tes user collection
const userModel = new Model(userSchema, process.env.COLLECTION_ID, process.env.DATABASE_ID);
const userRepository = new Repository(userModel);
// POST endpoint to create a new user
// add a new test user
app.post('/test', async (req, res) => {
try {

@@ -28,5 +39,7 @@ const user = await userRepository.create(req.body);

// GET endpoint to fetch a user by ID
// fetch a test user by ID
app.get('/test/:id', async (req, res) => {
try {
console.log(process.env.DATABASE_ID)
const user = await userRepository.findById(req.params.id);

@@ -39,5 +52,4 @@ res.status(200).json(user);

// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
{
"name": "appschema",
"version": "1.0.2",
"version": "1.0.3",
"description": "ODM for AppWrite DB",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

+105
-4
# AppSchema: ODM for AppWrite DB
**AppSchema** is an ODM (Object Data Model) for Appwrite DB that simplifies interactions with Appwrite databases. It provides a structured way to define models, handle validation, and perform database operations with ease.
## Features
- **Model Definition**: Define database models using JSON schemas.
- **Repository Pattern**: Abstract database operations such as create, read, update, and delete (CRUD).
- **Query Builder**: Build queries easily with various filtering operators.
- **Validation**: Built-in validation of data using AJV.
## Features that needs to be implemented
- **Advanced Query Support**: Support for more complex queries like AND, OR, IN, NOT IN, and BETWEEN conditions within the QueryBuilder. Paginate results with customizable page sizes and cursor-based pagination.
- **Soft Deletes**: Implement soft delete functionality for documents that should not be permanently deleted from the database
- **Schema Migration System**: Schema migration feature to handle changes to database structure, including adding/removing fields, and data transformations.
- **Hooks and Middleware**: Support for hooks such as beforeCreate, afterCreate, beforeUpdate, and afterDelete for extending the behavior of repositories. Custom actions before or after specific database operations.
- **Validation Enhancements**: Extend validation capabilities with custom validation rules.
- **Error Handling Improvements**: Implement custom error classes for specific error scenarios
- **Role-based Access Control (RBAC)**: role-based access control system for managing user permissions on model-level operations.
- **CLI Tooling**: Generating models, repositories, and running migrations
- **File Management Integration**: Appwrite’s file management service to support uploading, downloading, and associating files with models
- **Configuration Options**: Configuration options for customizing the behavior of the ODM to better suit various use cases.
- **Documentation and Examples**: Provide detailed documentation and examples for common use cases and advanced features.
- **Lot more can be built**: Do raise feature requests
## Installation
To install the AppSchema package, run:
```bash
npm install appschema
```
## Directory Structure
```
src/
```sh
lib/
├── index.ts # Entry point

@@ -11,3 +43,3 @@ ├── connection.ts # Appwrite connection handling

├── query.ts # Fluent query builder
└── repository.ts # CRUD operations
├── repository.ts # CRUD operations
└── schema.ts # Schema validation logic

@@ -18,2 +50,13 @@ ```

### Initialize Appwrite Connection
```javascript
const { AppwriteConnection } = require('appschema');
const endpoint = '<https://your-appwrite-server.com/v1>';
const projectId = 'your-project-id';
AppwriteConnection.initialize(endpoint, projectId);
```
### Connection Handling

@@ -27,3 +70,3 @@

```javascript
```typescript
import { Model } from './model';

@@ -50,1 +93,59 @@

```
or
```javascript
const { Model } = require('appschema');
const userSchema = {
type: 'object',
properties: {
name: { type: 'string', default: '' },
age: { type: 'number', default: 18 }
},
required: ['name', 'age'],
additionalProperties: false
};
const userModel = new Model(userSchema, 'your-collection-id', 'your-database-id');
```
### Perform DAL operations
```javascript
const { Repository } = require('appschema');
// Create a repository for the User model
const userRepository = new Repository(userModel);
const newUser = { name: 'John Doe', age: 30 };
userRepository.create(newUser).then((document) => {
console.log('Created document:', document);
}).catch((err) => {
console.error('Error creating document:', err);
});
```
### Builder queries
Note: This is not in production currently.
```javascript
const { QueryBuilder } = require('appschema');
// Build a query to find users older than 20
const query = new QueryBuilder()
.where('age', 'greaterThan', 20)
.build();
userRepository.find(query).then((documents) => {
console.log('Found documents:', documents);
});
```
## Contributing
Feel free to contribute by submitting a pull request or reporting issues.