连接连接的系统

概览

每种存储都有一个对象。 数据通过运行读写 () ; 计算机可获得两个额外的文件 和自己的外壳 。

run() everywherefiles and terminals on a computer only
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

就是这样 api.storage.create(), connect(), device(), get() 和 list() 全部手背。 你从不构建一个。 原因是它是一个单一类型, 整个资源点: 读取我们主机数据库的代码 读取你连接的代码 。

表面表面

成员日期 日期功能
运行( 配置)每个储存阅读和写数据。
文件 文件计算机那机器是自己的档案
终端终端计算机贝壳和服务器 寿命超过答案

随它携带的

idstring

识别资料, 传递给 storageId 任何人被要求的,无论在哪里。

labelstring

显示名称。 账户持有人可以更改它, 所以不能匹配它 。

typestring

filesystem · phone · browser · database · object. 字段到分支上。

providerstring

其背后的是什么呢? mongodb, d1, r2, s3, iagenify, machine, browser.

managedBystring

谁操作它。

servicestring|null

nosql · sql · object 在一个 IaGenify 云层储存。 null 否则。

isDefaultboolean

是否保存, 且此处没有目标位置 。

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.

设备是一个存储器, 保存自己的字节

类型类型类型其数据生命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")