orbitdb/src/db-manifest.js
haad d39b69a82f Refactor creating and saving DB manifest
Add test for loading an empty snapshot
2017-12-05 23:23:24 +01:00

15 lines
440 B
JavaScript

const path = require('path')
// Creates a DB manifest file and saves it in IPFS
const createDBManifest = async (ipfs, name, type, accessControllerAddress) => {
const manifest = {
name: name,
type: type,
accessController: path.join('/ipfs', accessControllerAddress),
}
const dag = await ipfs.object.put(Buffer.from(JSON.stringify(manifest)))
return dag.toJSON().multihash.toString()
}
module.exports = createDBManifest