data-exporter

This module

Using This Module

First add the module to your project:

npm install --save @obsidianjs/data-exporter

Then use it in your application (in your main index.js):

const obsidian = require("@obsidianjs/obsidian");
const dataExporter = require("@obsidianjs/data-exporter");

const app = obsidian("my-application");
app.use(dataExporter);
app.start();

Finally require it in modules that need it:

{
    name: "my-module",
    requires: ["data-exporter"],

    load(app) {
        const {dataExporter} = app.modules;
        // ...
    },

    // ...

}

Module API

class DataExporter()

Export (and import) data from the data-store module as an Obsidian Project File.

DataExporter.export(metadata={}, options={})

Exports data from the data-store module as an Obsidian Project File.

Arguments:
  • metadata (object) – Metadata that will be stored in the Obsidian Project File.
  • options (object) – Options related to the Obsidian Project File generation.
  • options.projectType (string) – The type of the project (see Obsidian Project File spec).
  • options.metadataFormat (number) – The format of the metadata section (see Obsidian Project File spec).
  • options.projectFormat (number) – The format of the project section (see Obsidian Project File spec).
  • options.blobIndexFormat (number) – The format of the blobIndex section (see Obsidian Project File spec).
Returns:

Buffer – The Obsidian Project File as a Node.js Buffer.

DataExporter.exportAsBlob(metadata, options)

Same as the export() method but returns a Blob.

DataExporter.exportAsData64(metadata, options)

Same as the export() method but returns a data64-encoded string.

DataExporter.import(obsidianProjectFile)

Imports data from an Obsidian Project file to the data-store module.

Arguments:
  • obsidianProjectFile (Buffer) – The Obsidian Project File as a Node.js Buffer.
DataExporter.importFromBlob(obsidianProjectFile)

Same as the import() method but takes a Blob.

Warning

Reading Blobs is an asynchronous operation, so this method is asynchronous and returns a promise.

Returns:Promise.<undefined>
DataExporter.importFromData64(obsidianProjectFile)

Same as the import() method but takes a data64-encoded string.