I wrote the code according to the access controller documentation, but an error occurs.
kk-0087 opened this issue · comments
I tried copying the wildcard part of the access controller documentation. However, when I try to run it with nodejs, I get an error saying "The requested module '@orbitdb/core' does not provide an export named 'getAccessController'".
code executed
import { create } from 'ipfs-core'
import { createOrbitDB, Identities, getAccessController } from '@orbitdb/core'
const ipfs = await create()
const orbitdb = await createOrbitDB({ ipfs })
const IPFSAccessController = getAccessController('ipfs')
const db = orbitdb.open('my-db', { AccessController: IPFSAccessController({ write: ['*'] }) })
out
import { createOrbitDB, Identities, getAccessController } from '@orbitdb/core'
^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@orbitdb/core' does not provide an export named 'getAccessController'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
When I looked at "@orbitdb/core", getAccessController was not exported.
export {
useAccessController,
IPFSAccessController,
OrbitDBAccessController
} from './access-controllers/index.js'`
Have the specifications changed?
Thanks for the heads up. That documentation looks out-dated so we will update asap.
You should be able to use IPFSAccessController
directly without having call it via getAccessController, so try changing the above to:
import { create } from 'ipfs-core'
import { createOrbitDB, Identities, IPFSAccessController } from '@orbitdb/core'
const ipfs = await create()
const orbitdb = await createOrbitDB({ ipfs })
const db = orbitdb.open('my-db', { AccessController: IPFSAccessController({ write: ['*'] }) })
and hopefully that will solve your issue.
Thanks all for the lighting fast response!
I'm going to close this issue but if you experience any further issues please re-open. We will also make a note to update the documentation accordingly.