All Projects → moleculerjs → database

moleculerjs / database

Licence: MIT License
Advanced Database Access Service for Moleculer microservices framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to database

blackmagic-espidf
Blackmagic Wireless SWD Debug probe hosted on esp-idf SDK (for ESP8266) with UART on Telnet port and HTTP using xterm.js
Stars: ✭ 165 (+650%)
Mutual labels:  adapter
laravel-casbin
This repository has moved to https://github.com/php-casbin/laravel-authz
Stars: ✭ 42 (+90.91%)
Mutual labels:  adapter
Swiperoo
An extendable adapter which provides swipe-to-delete feature on your customized row item
Stars: ✭ 38 (+72.73%)
Mutual labels:  adapter
ioBroker.vis-inventwo
Individualisierbare VIS Widgets für den ioBroker
Stars: ✭ 38 (+72.73%)
Mutual labels:  adapter
ioBroker.homepilot20
Rademacher Homepilot 2.0 (version >= 5.0.39)
Stars: ✭ 19 (-13.64%)
Mutual labels:  adapter
GraphQL.RepoDB
A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that enca…
Stars: ✭ 25 (+13.64%)
Mutual labels:  database-access
vscode-server-connector
📦 Connects Visual Studio Code to your server adapters and run, deploy apps !!
Stars: ✭ 41 (+86.36%)
Mutual labels:  adapter
moleculer-boilerplate-ts
[WIP] A Comprehensive Boilerplate for NodeJS micro-services project with moleculerjs.
Stars: ✭ 20 (-9.09%)
Mutual labels:  moleculer
RvAdapter
万能Adapter for RecyclerView.
Stars: ✭ 34 (+54.55%)
Mutual labels:  adapter
mongo orm
Mongo ORM: A simple ORM for using MongoDB with the crystal programming language, designed for use with Amber. Based loosely on Granite ORM. Supports Rails-esque models, associations and embedded documents.
Stars: ✭ 32 (+45.45%)
Mutual labels:  database-access
moleculer-http-client
HTTP client mixin that allows Moleculer services to communicate with remote REST APIs
Stars: ✭ 14 (-36.36%)
Mutual labels:  moleculer
RecyclerViewAdapter
A RecyclerView Adapter that support load more and add headerview
Stars: ✭ 145 (+559.09%)
Mutual labels:  adapter
moleculer-db
🔋 Database access service mixins for Moleculer
Stars: ✭ 117 (+431.82%)
Mutual labels:  moleculer
moleculer-java
Java implementation of the Moleculer microservices framework
Stars: ✭ 39 (+77.27%)
Mutual labels:  moleculer
hubot-dingtalk
hubot-dingtalk:支持钉钉Outgoing
Stars: ✭ 29 (+31.82%)
Mutual labels:  adapter
sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (+22.73%)
Mutual labels:  adapter
CodeBase-for-DBF
CodeBase is a C-based library to read, write and manage DBF type tables and indexes.
Stars: ✭ 38 (+72.73%)
Mutual labels:  database-access
dalesbred
Dalesbred - a database access library for Java
Stars: ✭ 50 (+127.27%)
Mutual labels:  database-access
twitter-for-geoevent
ArcGIS GeoEvent Server sample Twitter connectors for sending and receiving tweets.
Stars: ✭ 21 (-4.55%)
Mutual labels:  adapter
GenericAdapter
⛳️ Easy to use android databinding ready recyclerview adapter
Stars: ✭ 26 (+18.18%)
Mutual labels:  adapter

Moleculer logo

Integration Test Coverage Status Known Vulnerabilities NPM version

@moleculer/database

Advanced Database Access Service for Moleculer microservices framework. Use it to persist your data in a database.

This project is in work-in-progress. Don't use it in production.

this module follows the one database per service pattern. To learn more about this design pattern and its implications check this article. For multiple entities/tables per service approach check FAQ.

Features

  • multiple pluggable adapters (NeDB, MongoDB, Knex)
  • common CRUD actions for RESTful API with caching
  • pagination, field filtering support
  • field sanitizations, validations
  • read-only, immutable, virtual fields
  • field permissions (read/write)
  • ID field encoding
  • data transformation
  • populating between Moleculer services
  • create/update/remove hooks
  • soft delete mode
  • scopes support
  • entity lifecycle events
  • Multi-tenancy

Install

npm i moleculerjs/database nedb

Usage

Define the service

// posts.service.js

const DbService = require("@moleculer/database").Service;

module.exports = {
    name: "posts",
    mixins: [
        DbService({
            adapter: "NeDB"
        })
    ],

    settings: {
        fields: {
            id: { type: "string", primaryKey: true, columnName: "_id" },
            title: { type: "string", max: 255, trim: true, required: true },
            content: { type: "string" },
            votes: { type: "number", integer: true, min: 0, default: 0 },
            status: { type: "boolean", default: true },
            createdAt: { type: "number", readonly: true, onCreate: () => Date.now() },
            updatedAt: { type: "number", readonly: true, onUpdate: () => Date.now() }
        }
    }
}

Call the actions

// sample.js

// Create a new post
let post = await broker.call("posts.create", {
    title: "My first post",
    content: "Content of my first post..."    
});
console.log("New post:", post);
/* Results:
New post: {
  id: 'Zrpjq8B1XTSywUgT',
  title: 'My first post',
  content: 'Content of my first post...',
  votes: 0,
  status: true,
  createdAt: 1618065551990
}
*/

// Get all posts
let posts = await broker.call("posts.find", { sort: "-createdAt" });
console.log("Find:", posts);

// List posts with pagination
posts = await broker.call("posts.list", { page: 1, pageSize: 10 });
console.log("List:", posts);

// Get a post by ID
post = await broker.call("posts.get", { id: post.id });
console.log("Get:", post);

// Update the post
post = await broker.call("posts.update", { id: post.id, title: "Modified post" });
console.log("Updated:", post);

// Delete a user
const res = await broker.call("posts.remove", { id: post.id });
console.log("Deleted:", res);

Try it in your browser on repl.it

Documentation

You can find here the documentation.

Benchmark

There is some benchmark with all adapters. You can find the results here.

License

The project is available under the MIT license.

Contact

Copyright (c) 2022 MoleculerJS

@MoleculerJS @MoleculerJS

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].