This is what api.storage.create(), connect(), device(), get() and list() all hand back. You never construct one. The reason it is a single type is the point of the whole resource: the code that reads a database we host is the code that reads one you connected.
السطح
| العضو | & & & & | الوظيفة |
|---|---|---|
| تنفيذ | كل ما | يقرأ ويكتب البيانات |
| & لا شيء | )الحواسيب فقط( | تلك الآلة هي ملفاتها الخاصة |
| الميفادات | )الحواسيب فقط( | الصدفات و الخوادم التي تفوق على الإجابة |
ما الذي يحمله
idstring-المحددة. storageId أي مكان مطلوب
labelstringاسم العرض. صاحب الحساب يمكن أن يغيره ، لذا لا تطابقه.
typestringfilesystem · phone · browser · database · object. الحقل الذي يجب أن يفرع.
providerstringما هو وراءه mongodb, d1, r2, s3, iagenify, machine, browser.
managedBystringالذي يعمل عليه
servicestring|nullnosql · sql · object وضع IaGenify تخزين تخزين في التخزين. null (ب) أو
isDefaultbooleanIF a حفظ مع لا هدف هنا.
machineId · hostnamestring|nullعلى حاسوب: أي آلة.
deviceIdstring|nullعلى الهاتف: تحديد المتصفح يحتفظ به.
limitsobjectما هي مسارات التخزين في الفضاء الخاص بها.
lastActivityAt · createdAtstring|nullعندما كان يستخدم آخر مرة، وعندما كان مسجلا.
ما زودته بالإتصال يستخدم من قبل الخادم للاتصال ولا يتم تسليمه أبداً. لا شيء هنا يمكن أن يتسرب كلمة مرور عن طريق الدخول أو الإرسال إلى صفحة.
الفرع على أساس نوع الفرع، لا على أساس مقدِّم الخدمات
provider (أ) أن تخبركم بما يوجد وراء التخزين؛ type و الثانية هي ما يجب أن تختبره شفرتك
for (const storage of await api.storage.list()) {
switch (storage.type) {
case "database":
await storage.run({ action: "collections" });
break;
case "object":
await storage.run({ action: "list" });
break;
case "filesystem":
await storage.files.list(); // this machine's own files
break;
case "phone":
case "browser":
// Its files are in its browser — reachable from the page, not from here.
break;
}
}for storage in api.storage.list():
if storage.type == "database":
storage.run(action="collections")
elif storage.type == "object":
storage.run(action="list")
elif storage.type == "filesystem":
storage.files.list() # this machine's own files
elif storage.type in ("phone", "browser"):
pass # Its files are in its browser — reachable from the page, not from here.A أداة a a تخزين يُبقي خاصّته أداء
| نوع | بياناته | run() | & لا شيء |
|---|---|---|---|
| :: الجسم | على الحساب | نعم | لا: |
| أنت | على تلك الآلة | :: أن يكون محلياً | نعم - على تلك الآلة |
| ميكرو ميكرو ميكرو ميكرو ميكرو | في ذلك المتصفح | :: أن يكون محلياً | لا - انظر الجسر |
على أي شيء ليس حاسوباً، الوصول إلى الملفات storage_not_local - - - أو - storage_is_phone على الهاتف، الذي يقول أين الملفات هي في الواقع. اختبار النوع أولاً؛ نتيجة فارغة ستكون كذبة.
import { IaGenifyError } from "iagenify";
try {
await storage.files.list();
} catch (err) {
if (err instanceof IaGenifyError && err.code === "storage_not_local") {
// Not a computer. Its data is read through run().
}
}# In Python, files is None on anything that is not a computer:
# its data is read through run().
if storage.files is None:
storage.run(action="collections")
else:
storage.files.list()نفس الشيء، أينما جاء من
const ours = await api.storage.create({ service: "nosql", label: "App data" });
const yours = await api.storage.connect({ label: "Prod", type: "database", provider: "mongodb",
endpoint: { credentials: { uri } } });
// Identical calls, different backends
for (const base of [ours, yours]) {
await base.run({ action: "count", collection: "events" });
}ours = api.storage.create(service="nosql", label="App data")
yours = api.storage.connect(label="Prod", type="database", provider="mongodb",
endpoint={"credentials": {"uri": uri}})
# Identical calls, different backends
for base in (ours, yours):
base.run(action="count", collection="events")