MongoDB Access Layer.

Mongalayer is a type-safe abstraction layer between your MongoDB database and TypeScript clients, designed for basic CRUD applications. Define schemas with Zod, control access through role-based definitions, and query your data with full type safety — from server to client.
<script setup lang="ts">
import { Project } from "model/project";

const { $database } = useNuxtApp();

const allProjects: Ref<Project[]> = ref([]);

onMounted(async () => {
    allProjects.value = await $database.collection<Project>("projects").find();
});
</script>

Key Features

    Role-Based Access Control
    Define granular access roles with document-level and field-level permissions. Control who can read, create, update, and delete data.
    Schema Validation
    Define your document schemas with Zod. All payloads are validated automatically before reaching MongoDB.
    Full Type Safety
    End-to-end TypeScript types from server to client. Actions, payloads, and return types are all fully typed.
    MongoDB CRUD Operations
    Supports find, findOne, findOneAndUpdate, aggregate, insertOne, insertMany, updateOne, updateMany, deleteOne, and deleteMany from your client code.
    Client SDK
    A lightweight client library that communicates with the Mongalayer server over HTTP. Works in any JavaScript environment with fetch.
    Bring Your Own Auth
    Authentication and authorization of HTTP requests is handled by you. Mongalayer focuses on data access control, not transport security.
Copyright © 2026