Create your own data origin

Imbricate as a notes platform that allows you to create, read, update, and delete data from different sources. The data origin is the source of the data, it can be a file, a database, or an API. This guide will show you how to create your own data origin.

@imbricate/core is the core package that provides the interfaces and types to create a data origin. The data origin is a class that implements the IImbricateOrigin interface.

Install the @imbricate/core package:

bash
npm install @imbricate/core

§ Implement database and database manager

Imbricate see everything as a document, and database contains documents. To implement a database in Imbricate, there's unnecessary to be a real SQL/NOSQL database, but something that can be abstracted to a database. In this guide, we will create a simple Imbricate data origin to store data in memory.

ts
import { IImbricateDatabaseManager, IImbricateOrigin, IImbricateStaticManager, ImbricateSearchResult } from "@imbricate/core";

export class MyOrigin implements IImbricateOrigin {

    public get uniqueIdentifier(): string {
        return return "my-origin";
    }

    public getDatabaseManager(): IImbricateDatabaseManager {
        // TODO
    }

    public getTextManager(): ImbricateStackAPITextManager {
        // TODO
    }

    public async search(
        keyword: string,
    ): Promise<ImbricateSearchResult> {
        // TODO
    }
}