script.io.js 2026.122.1019 → 2026.122.1345
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/node_packages/script.js +46 -1
- package/package.json +1 -1
package/index.js
CHANGED
package/node_packages/script.js
CHANGED
|
@@ -353,6 +353,7 @@ Define (JSON.db.file, "object", {});
|
|
|
353
353
|
Define (Function, "path", function () {});
|
|
354
354
|
Define (Function.path, "require", function () { return Function.path.api = require ("path"); });
|
|
355
355
|
Define (Function.path, "join", function (... path) { return Function.path.api.join (... path); });
|
|
356
|
+
Define (Function.path, "current", function (path) { return "./" + path; });
|
|
356
357
|
|
|
357
358
|
/**
|
|
358
359
|
* file
|
|
@@ -380,7 +381,7 @@ Define (Function.file, "read", function (file, context) { if (context) return Fu
|
|
|
380
381
|
*/
|
|
381
382
|
|
|
382
383
|
/**
|
|
383
|
-
*
|
|
384
|
+
* appwrite
|
|
384
385
|
*
|
|
385
386
|
* title
|
|
386
387
|
* description
|
|
@@ -389,6 +390,49 @@ Define (Function.file, "read", function (file, context) { if (context) return Fu
|
|
|
389
390
|
* xxx://xxx.xxx.xxx/xxx
|
|
390
391
|
*/
|
|
391
392
|
|
|
393
|
+
Define (Function, "appwrite", function () {});
|
|
394
|
+
Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
|
|
395
|
+
|
|
396
|
+
Define (Function.appwrite, "db", class {
|
|
397
|
+
constructor (config) {
|
|
398
|
+
this.config = config;
|
|
399
|
+
this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
|
|
400
|
+
if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
|
|
401
|
+
}
|
|
402
|
+
select (collection) { return new Function.appwrite.db.select (this, collection); }
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
Define (Function.appwrite.db, "select", class {
|
|
406
|
+
constructor (db, collection) {
|
|
407
|
+
this.db = db;
|
|
408
|
+
this.collection = {name: collection, id: Function.appwrite.db.collection (collection)}
|
|
409
|
+
}
|
|
410
|
+
find (filter = {}) {
|
|
411
|
+
var __ = function (db) {
|
|
412
|
+
return new Promise (async function (resolve, reject) {
|
|
413
|
+
var error = false;
|
|
414
|
+
try {
|
|
415
|
+
var database = new Function.appwrite.api.Databases (db.db.client);
|
|
416
|
+
var result = await database.listDocuments ({
|
|
417
|
+
databaseId: db.db.config.id,
|
|
418
|
+
collectionId: db.collection.id,
|
|
419
|
+
queries: [
|
|
420
|
+
Function.appwrite.api.Query.limit (5000),
|
|
421
|
+
],
|
|
422
|
+
total: true,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
catch (e) { error = true; }
|
|
426
|
+
resolve ({error, data: result.documents.map (function (data) { data.id = data.$id; return data; }).select (filter)});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
return __ (this);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
Define (Function.appwrite.db, "collection", function (key, value) { if (value) return Function.appwrite.db.collection.object [key] = value; else return Function.appwrite.db.collection.object [key] || key; });
|
|
434
|
+
Define (Function.appwrite.db.collection, "object", {});
|
|
435
|
+
|
|
392
436
|
/**
|
|
393
437
|
* xxx
|
|
394
438
|
*
|
|
@@ -573,6 +617,7 @@ Symbol.export = {
|
|
|
573
617
|
url: URL, json: JSON,
|
|
574
618
|
path: Function.path, file: Function.file, dir: Function.dir,
|
|
575
619
|
html: Function.html,
|
|
620
|
+
appwrite: Function.appwrite,
|
|
576
621
|
}
|
|
577
622
|
|
|
578
623
|
/**
|
package/package.json
CHANGED