首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Orbitdb是否有额外的依赖关系?

Orbitdb是否有额外的依赖关系?
EN

Stack Overflow用户
提问于 2020-06-26 01:54:13
回答 1查看 85关注 0票数 0

对于使用IPFS的Orbitdb,可能有一些额外的依赖项,这些依赖项在任何地方都没有特别提到。我尝试从文档中创建一个简单的键值db:

orbit.js

代码语言:javascript
复制
const IPFS = require("ipfs");
const OrbitDB = require("orbit-db");

    const ipfsOptions = {
      EXPERIMENTAL: {
        pubsub: true
      }
    };

    const ipfs = await IPFS.create(ipfsOptions);
    const orbitdb = await OrbitDB.createInstance(ipfs);
    const db = await orbitdb.create("test", "keyvalue", {
      overwrite: true,
      replicate: true,
      accessController: {
        type: "ipfs",
        admin: ["*"],
        write: ["*"]
      }
    });
    await db.set("hello", "world");
    console.log(db.all);

我的package.json中有以下依赖项

代码语言:javascript
复制
"dependencies": {
    "ipfs": "^0.46.0",
    "orbit-db": "^0.24.1"
}

它抛出了以下错误:

Trace: Error: Could not append entry, key "..." is not allowed to write to the log

我试着解决它,但似乎什么都不起作用。现在,有趣的部分来了。因此,我目前正在开发使用Orbitdb的代码的前端部分。出于好奇,我将orbit.js文件复制粘贴到了包含前端代码的根文件夹中。在那里运行相同的文件,运行得很好,成功地创建了数据库!以下是前端代码(在Angular中)的package.json中的所有依赖项和开发依赖项:

代码语言:javascript
复制
  "dependencies": {
    "@akveo/ng2-completer": "^9.0.1",
    "@angular/animations": "^9.0.4",
    "@angular/cdk": "^9.1.2",
    "@angular/common": "^9.0.4",
    "@angular/compiler": "^9.0.4",
    "@angular/core": "^9.0.4",
    "@angular/forms": "^9.0.4",
    "@angular/google-maps": "^9.1.0",
    "@angular/material": "^9.1.0",
    "@angular/platform-browser": "^9.0.4",
    "@angular/platform-browser-dynamic": "^9.0.4",
    "@angular/router": "^9.0.4",
    "@asymmetrik/ngx-leaflet": "3.0.1",
    "@nebular/auth": "5.0.0",
    "@nebular/eva-icons": "5.0.0",
    "@nebular/security": "5.0.0",
    "@nebular/theme": "5.0.0",
    "@swimlane/ngx-charts": "^13.0.2",
    "angular2-chartjs": "0.4.1",
    "bootstrap": "4.3.1",
    "chart.js": "^2.9.3",
    "ckeditor": "4.7.3",
    "classlist.js": "1.1.20150312",
    "core-js": "2.5.1",
    "env-paths": "^2.2.0",
    "eva-icons": "^1.1.3",
    "intl": "1.2.5",
    "ionicons": "2.0.1",
    "ipfs": "^0.46.0",
    "it-all": "^1.0.2",
    "leaflet": "1.2.0",
    "metamask-logo": "^2.2.1",
    "nebular-icons": "1.1.0",
    "nedb": "^1.8.0",
    "ng2-ckeditor": "^1.2.2",
    "ng2-smart-table": "^1.6.0",
    "node-sass": "^4.14.1",
    "normalize.css": "6.0.0",
    "orbit-db": "^0.24.1",
    "pace-js": "1.0.2",
    "roboto-fontface": "0.8.0",
    "rxjs": "6.5.4",
    "rxjs-compat": "6.3.0",
    "socicon": "3.0.5",
    "style-loader": "^1.1.3",
    "test-ipfs-example": "^2.0.3",
    "tinymce": "4.5.7",
    "tslib": "^1.10.0",
    "typeface-exo": "0.0.22",
    "web-animations-js": "^2.3.2",
    "web3": "^1.2.9",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.7",
    "@angular/cli": "^9.0.4",
    "@angular/compiler-cli": "^9.0.4",
    "@angular/language-service": "9.0.4",
    "@compodoc/compodoc": "^1.1.11",
    "@fortawesome/fontawesome-free": "^5.2.0",
    "@types/d3-color": "1.0.5",
    "@types/googlemaps": "^3.39.3",
    "@types/jasmine": "2.5.54",
    "@types/jasminewd2": "2.0.3",
    "@types/leaflet": "1.2.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "conventional-changelog-cli": "1.3.4",
    "husky": "0.13.3",
    "jasmine-core": "2.6.4",
    "jasmine-spec-reporter": "4.1.1",
    "karma": "1.7.1",
    "karma-chrome-launcher": "2.1.1",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.3.0",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "npm-run-all": "4.0.2",
    "protractor": "5.1.2",
    "rimraf": "2.6.1",
    "stylelint": "7.13.0",
    "ts-node": "3.2.2",
    "tslint": "^5.7.0",
    "tslint-language-service": "^0.9.9",
    "typescript": "3.7.5"
  }

我知道这些依赖关系中的大多数甚至都与Orbitdb无关,我绝对可以将它们缩小到特定的依赖关系,但有人能解释一下为什么它在这里工作吗?我对Orbitdb的使用完全陌生。

EN

回答 1

Stack Overflow用户

发布于 2020-06-26 18:44:05

OrbitDB已经正确处理了它的依赖关系

你的代码应该可以工作,你甚至可以简化它

代码语言:javascript
复制
const start = async () => {
  const ipfs = await IPFS.create();
  const orbitdb = await OrbitDB.createInstance(ipfs);
  const db = await orbitdb.create("test", "keyvalue", {
    overwrite: true,
    replicate: true,
    accessController: {
      write: ["*"],
    },
  });
  await db.set("hello", "world");
  console.log(db.all);
  db.close();
  ipfs.stop();
};

start();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62581453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档