From 8e12c10cd711240cc4b8629c25ccaeeabea489f9 Mon Sep 17 00:00:00 2001 From: mohamed yahia Date: Tue, 12 Dec 2023 17:46:10 +0200 Subject: [PATCH] Update the example --- examples/document-types/README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/document-types/README.md b/examples/document-types/README.md index ab9f850..2a13850 100644 --- a/examples/document-types/README.md +++ b/examples/document-types/README.md @@ -1,10 +1,20 @@ # MarkdownDB Schemas Configuration Tutorial -MarkdownDB empowers you to establish and enforce the structure of your Markdown content using the Zod library for schema definitions. This tutorial guides you through the process of defining schemas for a blog post, ensuring a mandatory `date` field. The schemas play a crucial role in error prevention and ensure the predicted structure in Markdown files. +MarkdownDB enables you to establish and enforce the structure of your Markdown content using the Zod library for schema definitions. This tutorial guides you through the process of defining schemas for a blog post, ensuring a mandatory `date` field. The schemas play a crucial role in error prevention and ensure the predicted structure in Markdown files. ## Define Your Schemas -Create a configuration object and use the Zod library to define your schemas. For more information on defining Zod schemas, visit [Zod Documentation - Basic Usage](https://zod.dev/?id=basic-usage). In this example, we'll begin by creating a schema for a blog post. +Create a configuration object and use the Zod library to define your schemas. For more information on defining Zod schemas, visit [Zod Documentation - Basic Usage](https://zod.dev/?id=basic-usage). +In this example, we'll begin by creating a schema for a blog post. For instance: +```md +--- +title: blog post +date: 2023-12-05 +... +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. +``` Subsequently, we'll use the `client.indexFolder` method along with the defined schemas to scan and index the folder containing your Markdown files. @@ -13,9 +23,6 @@ Subsequently, we'll use the `client.indexFolder` method along with the defined s import { z } from "zod"; import { MarkdownDB } from "mddb"; -// Code for initializing the connection -const client = /_ Initialize your connection here _/; - // Define the schemas using Zod const schemas = { post: z.object({ @@ -26,6 +33,15 @@ const schemas = { }), }; +// Code for initializing the connection +const client = new MarkdownDB({ + client: "sqlite3", + connection: { + filename: "markdown.db", + }, +}); +const mddb = await client.init(); + // Index the folder with MarkdownDB await client.indexFolder({ folderPath: contentPath,