• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A MongoDB ODM for Deno
dangoDB logo

dangoDB

A MongoDB ODM for Deno



Table of Contents

  1. Description
  2. Getting Started
  3. Query
  4. Schema
  5. Authors
  6. License

Description

dangoDB is a light-weight MongoDB Object Document Mapper (ODM) library built for the Deno runtime. It provides the core functionality and familiar look and feel of established Node-based libraries. With dangoDB, developers can construct schemas and models, and they can enforce strict type-casting and schema validation to structure their databases. The query functions available from the deno_mongo driver can all be accessed with ease.

In addition, we built a user-friendly web-based GUI that auto-generates schema for users to copy and paste directly into their code.

Getting Started

First, be sure that you have Deno runtime installed and configured.

Quick Start

In your application, import the dangoDB module from the deno.land module.

import { dango } from "https://deno.land/x/[email protected]/mod.ts";

Connect to your Database

Next, open a connection to your MongoDB database using your URI string.

await dango.connect('URI_STRING');

await dango.disconnect();

Define Your Schema

Now, you can define a schema and create a reference to it as illustrated below.

const dinosaurSchema = dango.schema(
  {
    name:                 // A property accepts the below options. Only type is required and must be a valid selection.
      { 
        type: 'string',   // Valid data types listed below.
        required: true,   // A boolean to indicate if the inserted property must have a value specified. Defaults to false.
        unique: true,     // A boolean to indicate if the inserted property much be unique in its value in the collection. Defaults to false.
        default: 'T-Rex', // A value to default to if none specified and required = false. Defaults to null.
        validator: null   // A user provided validation function that must return true with the casted value as input for the data to pass schema validation. Defaults to null.
      },
    age: 'number',        // A property can also accept a schema value with only a type indicated.
  }
);

/**
*  Valid datatypes:
*  - 'number'
*  - 'decimal128'
*  - 'string'
*  - 'boolean'
*  - 'objectid'
*  - 'uuid'
*  - 'date'
*  - userSchema            // User defined schema.
*  - array **              // In progress - Not yet implemented.
*
*/

Create Your Model

Great! Now you have a schema with one property, name, which will be a 'string.' The next step is compiling our schema into a Model.

const Dinosaur = dango.model('Dinosaur', dinosaurSchema);

Make a Query

Now, let's insert a document into the Dinosaur model.

await Dinosaur.insertOne({ name: 'Stegosaurus' });

Now, let's say you wanted to display all the dinosaurs in our collection. You can access all of the dinosaur documents through our Dinosaur model.

const dinosaurs = await Dinosaur.find({ });
console.log(dinosaurs); 
// [ { name: 'Triceratops', age: 70,000,000 }, { name: 'Brontosaurus', age: 150,000,000 }, { name: 'Stegosaurus', age: null }];

Now you've successfully inserted a document into the Dinosaur collection at your MongoDB database.

Congratulations! That's the end of the quick start. You've successfully imported dangoDB, opened up a connection, created a schema, inserted a document for Stegosaurus, and queried all the dinosaurs in your Dinosaur model using dangoDB. Explore the rest of the readme.MD for more detailed instructions on how to use dangoDB.

Query

All queries in dangoDB are performed using models. The queries are built on the deno_mongo drivers. The documentation there may help guide query options. Listed below are all the query functions available in the dangoDB library.

Create, Read, Update, Delete Operations

  • Model.deleteMany()
Model.deleteMany()
/**
* @description Deletes all of the documents that match the conditions from the DB collection. It returns an object with 
* the property deletedCount, indicating how many documents were deleted. 
* @param queryObject - Query to specify which documents to delete.
* @param options - [optional]
* @param callback - [callback]
* @returns object with property deletedCount, value number. 
*/
  • Model.deleteOne()
Model.deleteOne()
/**
* @description Deletes the first document that matches the conditions from the DB collection. It returns an object 
* with the property deletedCount, indicating how many documents were deleted. 
* @param queryObject - The query used to find matching document.
* @param options [optional]
* @param callback [optional]
* @returns object with property deletedCount, value number.
*/
  • Model.find()
Model.find()
/**
* @ description Returns all documents that satisfy the specified query criteria on the collection or view. 
* @param queryObject - The query used to find matching documents.
* @param options - [optional] Additional options for the operation (e.g. lean, populate, projection)
* @param callback - [optional]
* @returns All matching documents in an array.
*/
  • Model.findById()
Model.findById()
/**
* @description Returns document that matches user provided ObjectId.
* @param queryObject - The query used to find matching document, using id.
* @param options - [optional] - Additional options for the operation (e.g. lean, populate, projection)
* @param callback - [optional]
* @returns Matching document.
*/
  • Model.findByIdAndDelete()
Model.findByIdAndDelete()
/**
* @description Deletes the first document that matches the id from the DB collection. It returns the document 
* with the matched property. 
* @param queryObject - The query used to find matching document, using id.
* @param options [optional]
* @param callback [optional]
* @returns the deleted document.
*/
  • Model.findByIdAndRemove()
Model.findByIdAndRemove()
/**
* @description Deletes the first document that matches the id from the DB collection. It returns the document 
* with the matched property. 
* @param queryObject - The query used to find matching document, using id.
* @param options [optional]
* @param callback [optional]
* @returns the document matched and removed.
*/
  • Model.findByIdAndUpdate()
Model.findByIdAndUpdate()
/**
* @description Updates the first document that matches the id from the DB collection. It returns the document 
* with the matched property. 
* @param filter - id used to find matching document.
* @param replace - User document to replace matching document at database.
* @param callback [optional]
* @returns the document matched.
*/
  • Model.findOne()
Model.findOne()
/**
* @description Returns first document that matches query.
* @param queryObject - Query used to find matching document. 
* @param options - [optional]
* @param callback - [optional]
* @returns Matching document.
*/
  • Model.findOneAndDelete()
Model.findOneAndDelete()
/**
* @description Deletes the first document that matches the filter from the DB collection. It returns the document 
* with the matched property. 
* @param queryObject - The query used to find matching document.
* @param options [optional]
* @param callback [optional]
* @returns the deleted document.
*/
  • Model.findOneAndRemove()
Model.findOneAndRemove()
/**
* @description Deletes the first document that matches the filter from the DB collection. It returns the document 
* with the matched property. 
* @param queryObject - The query used to find matching document.
* @param options [optional]
* @param callback [optional]
* @returns the deleted document.
*/
  • Model.findOneAndReplace()
Model.findOneAndReplace()
/**
* @description Finds a matching document, removes it, and passes in user's document. Replacement document retains same ObjectId as original document. 
* @param filter - Query used to find matching document.
* @param replace - User document to replace matching document at database.
* @param options - [optional]
* @param callback - [optional]
* @returns object displaying count for how many documents were upserted, matching, modified.
*/
  • Model.findOneAndUpdate()
Model.findOneAndUpdate()
/**
* @description Updates the first document that matches filter from the DB collection. It returns the document 
* with the matched property. 
* @param filter - id used to find matching document.
* @param replace - User document to replace matching document at database. 
* @param callback [optional]
* @returns the document matched.
*/
  • Model.insertOne()
Model.insertOne()
/** 
* @description Inserts one document into database collection. 
* @param document - User provided object to be inserted into the database.
* @returns ObjectId of inserted document.
*/
  • Model.insertMany()
Model.insertMany()
/**
* @description Insert multiple documents into database. 
* @param document - Array of document(s) to be inserted into database.
* @param options - [optional] 
* @param callback - [optional]
* @returns documents that passed validation.
*/
  • Model.replaceOne()
Model.replaceOne()
/**
* @description Finds a matching document, removes it, and passes in user's document. Replacement document retains same ObjectId as original document. 
* @param filter - Query used to find matching document.
* @param replace - User document to replace matching document at database. 
* @param options - [optional]
* @param callback - [optional]
* @returns The updated object.
*/
  • Model.updateMany()
Model.updateMany()
/**Parameters:
* @description Updates all documents that match queryObject. The matching fields in the DB collection will be set to the values in the updateObject.
* @param document - query used to find document(s) to update.
* @param update - object containing field(s) and values to set them to.
* @param options - [optional]
* @param callback - [optional]
* @returns object with properties upsertedId, upsertedCount, matchedCount, modifiedCount.
*/
  • Model.updateOne()
Model.updateOne()
/**
* @description Updates one document. The fields in the updateObject will be set to their respective values.
* @param document - query used to find document to update.
* @param update - object containing field(s) and values to set them to.
* @param options - [optional]
* @param callback - [optional]
* @returns object with properties upsertedId, upsertedCount, matchedCount, modifiedCount.
*/

Other Operations

  • Model.aggregate()
Model.aggregate()
/**
* @ description Aggregation operations process multiple documents and return computed results. You can use aggregation operations to:
* Group values from multiple documents together.
* Perform operations on the grouped data to return a single result.
* Analyze data changes over time.
* @param Aggregation pipeline as an array of objects.
* @returns Documents returned are plain javascript documents; 
*/
  • Model.countDocuments()
/**
Model.countDocuments()
* @description Counts number of documents matching filter in a database collection.
* @param document - query used to find document to update. 
* @param options - [optional]
* @param callback - [optional]
* @returns a count (number);
* example: query.countDocuments({ username: 'test' });
*/
  • Model.dropCollection()
Model.dropCollection()
/**
* @description DropCollection drops current model/collection that user is connected to.
* @returns undefined
*/
  • Model.estimatedDocumentCount()
Model.estimatedDocumentCount()
/**
* @description Returns the count of all documents in a collection or view. The method wraps the count command.   
* @param options - [optional]
* @param callback - [optional]
* @returns a count (number);
*/

Schema

When creating a schema, either a type can be assigned to each property in string format, or an object with schema options properties.

Schema Options

  • type - Number, decimal128, string, boolean, objectid, UUID, date, object. Specified as a lowercase string.
  • required - Boolean, specifies whether a value is required in an inserted document or replacement document.
  • unique - Boolean, specifies whether a value is designated as unique for the property.
  • default - Default value if no value is provided by user. Defaults to null.
  • validator - User can provide a function test which the values to be inserted/updated need to pass before being inserted. Defaults to null.

To set the type for an embedded object, create a schema for that object, and assign that schema to the property that corresponds with the object.

addressSchema = dango.schema(
  {
    house_number: 'number', 
    unit: 'string', 
    street: 'string', 
    city: 'string'
  }
);

personSchema = dango.schema(
  { 
    name: 'string', 
    address: addressSchema 
  }
);

Authors

License

This product is licensed under the MIT License - see the LICENSE file for details.

This is an open source product.

This product is accelerated by OS Labs.

More Repositories

1

sapling

Sapling - A convenient way to traverse your React app in VS Code
JavaScript
489
star
2

Kafka-Sprout

πŸš€ Web GUI for Kafka Cluster Management
Java
429
star
3

GraphQuill

Real-time GraphQL API Exploration in VS Code
TypeScript
395
star
4

protographql

ProtoGraphQL is a prototyping tool that empowers developers to build and visualize GraphQL schemas and queries without writing any code.
JavaScript
360
star
5

seeql

see your database in a new way
TypeScript
344
star
6

Realize

A React component tree visualizer
JavaScript
327
star
7

Allok8

⚑️A pretty swell Kubernetes visualization tool
JavaScript
273
star
8

ReactRTC

NPM package that simplifies set-up of WebRTC as importable React components
JavaScript
270
star
9

svend3r

Interactive plug and play charting library for Svelte
JavaScript
267
star
10

aether

All-in-One Memory Leak Testing Solution
JavaScript
250
star
11

Yodelay

Your preferred gRPC endpoint testing tool. Making sure your outbound πŸ—£οΈ β€˜yodelay’ returns the β€˜IiiOoo’ πŸ“£ that you expect
TypeScript
228
star
12

ReactRPC

Full feature integration library for gRPC-Web into React
JavaScript
224
star
13

atomos

Atomos is an open source dev tool for Recoil that provides real-time visualization of the component tree and atom-selector relationships to facilitate debugging of a React application.
JavaScript
218
star
14

Dockter

A low-overhead, open-source Docker log management tool
TypeScript
217
star
15

svelte-sight

A Svelte dev tool for visualizing component hierarchy, state, and props of your application
Svelte
215
star
16

KUR8

A visual overview of Kubernetes architecture and Prometheus metrics
JavaScript
213
star
17

OpticQL

Developer tool focused on streamlining the performance testing and optimization of GraphQL API
JavaScript
212
star
18

connext-js

A middleware and route handling solution for Next.js.
JavaScript
210
star
19

hypnos

The best way to test GraphQL calls to RESTful APIs.
JavaScript
205
star
20

Equa11y

A stream-lined command line tool for developers to easily run accessibility testing locally through axe-core and puppeteer.
TypeScript
204
star
21

preducks

React/Redux/Typescript Application Prototyping & Smart Boilerplate Generation Tool
TypeScript
199
star
22

drawql

an OSS tool for designing a graphql endpoint in Apollo
CSS
195
star
23

kubermetrics

JavaScript
194
star
24

TotalRecoilJS

TotalRecoilJS is a tool created to help developers visualize/debug and track their Recoil state via a Chrome extension.
JavaScript
193
star
25

Horus

🎯 A gRPC-Node Distributed Tracing and Monitoring Tool.
JavaScript
187
star
26

PostQL

Web app to visualize your GraphQL metrics and provide historical analytics
TypeScript
186
star
27

Ahoy

Ahoy! is a GUI tool for DevOps engineers which distills the many functions of Helm into a user-friendly interface.
JavaScript
183
star
28

battletest

A CLI module for npm that auto-generates tests based on user specified parameters.
JavaScript
183
star
29

Deno-Redlock

Deno's first lightweight, secure distributed lock manager utilizing the Redlock algorithm
TypeScript
182
star
30

ReactMonitor

Quickly visualize React's component tree and its performance
JavaScript
181
star
31

Osiris

An Electron based desktop application for generating components, building pages, and storing them in a UI library.
JavaScript
177
star
32

protostar-relay

Open-source iteration of the official Relay devtool.
JavaScript
171
star
33

TorchQL

A tool to quickly generate GraphQL schemas and resolvers from a relational database
JavaScript
171
star
34

trydent

testing tamed
TypeScript
170
star
35

genesisQL

rapid schema-prototyping tool for GraphQL applications
JavaScript
169
star
36

FilamentQL

GraphQL query and caching solution
JavaScript
168
star
37

GatsbyHub

Access everything Gatsby has to offer without ever leaving Visual Studio Code. This VSCode Extension allows you to generate a new Gatsby site using a starter, browse Gatsby plugins, and develop a server all with a click of a button.
TypeScript
163
star
38

aditum

Accessibility components for managing focus in React SPAs
JavaScript
162
star
39

watchmo

JavaScript
162
star
40

react-chronoscope

Developer tool to monitor React performance
JavaScript
162
star
41

navigate

A Kubernetes cluster visualizer for DevOps engineers - network policies, aggregated scheduler logs, deployments and pods before your cluster is running!
TypeScript
161
star
42

TrunQ

NPM package for easy client and/or server side graphQL caching.
JavaScript
160
star
43

onyx

Onyx is authentication middleware for Deno, inspired by Passport.js
TypeScript
159
star
44

BACE

JavaScript
159
star
45

MASH

Kafka visualizer and management suite
TypeScript
158
star
46

portara

Portara directive is a rate limiter / throttler for GraphQL
TypeScript
158
star
47

irisql

GraphQL prototyping tool to quickly mock-up Node API's and visualize where you can query from.
JavaScript
158
star
48

Interspect

An API mocking tool for testing data interoperability between microservices and secure HTTP endpoints
JavaScript
157
star
49

SMEE

JavaScript
154
star
50

ChaosQoaLa

Chaos Engineering meets GraphQL
JavaScript
153
star
51

VaaS

Modular Kubernetes Management System with OpenFaaS Support
TypeScript
153
star
52

tropicRPC

A VS Code extension that provides gRPC API endpoint testing.
TypeScript
153
star
53

dashport

Local and OAuth authentication middleware for Deno
TypeScript
151
star
54

anagraphql

JavaScript
151
star
55

Trinity

A VSCode extension for Cypher and Neo4j
TypeScript
150
star
56

DockerLocal

DockerLocal is a GUI application that allows you to keep an up-to-date version of the docker compose file for interconnected repositories while doing development work on a single repository.
TypeScript
150
star
57

giraffeQL

πŸ¦’ Developer tool to visualize relational databases and export schemas for GraphQL API's.
JavaScript
147
star
58

ProtoCAD

ProtoCAD is a prototyping tool that allows developers to build UI component tree structure based on GraphQL query results.
TypeScript
146
star
59

Trace

A lightweight GraphQL query performance monitoring GUI with real-time, resolver-level performance tracing metrics and error logging.
TypeScript
146
star
60

StratosDB

β˜„οΈ ☁️ An All-in-One GUI for Cloud SQL that can help users design and test their AWS RDS Instances
TypeScript
145
star
61

snAppy

snAppy is a VS Code extension coupled with an interactive view to support your React front-end delivery.
TypeScript
144
star
62

synapse

Realtime API Library
TypeScript
144
star
63

SpectiQL

GraphQL query, mutation, subscription test generator
JavaScript
143
star
64

starfleet

Command line tool to generate GraphQL services from Mongoose schemas with full CRUD functionality and deploy them to the cloud
JavaScript
143
star
65

pelican

Automated GUI canary testing for your kubernetes clusters
JavaScript
140
star
66

ProtoNative

A React Native prototyping tool for developers.
TypeScript
140
star
67

reactFLO

A Chrome DevTool built for developers to visualize the flow of state throughout their application.
TypeScript
140
star
68

ReactionTime

ReactionTime provides a simpler way to write tests for React's Experimental Concurrent Mode.
TypeScript
140
star
69

DacheQL

GraphQL caching tool
JavaScript
139
star
70

KuberOptic

An Electron app for developers to visualize their Kubernetes clusters in real-time
TypeScript
137
star
71

sono.land

Real-time Communication Library for Deno (WebSockets & WebRTC)
TypeScript
137
star
72

KubeScrape

KubeScrape: An open-source dev tool that provides an intuitive way to view the health, structure, and live metrics of your Kubernetes cluster
JavaScript
136
star
73

LucidQL

A developer tool and visualizer that generates a GraphQL schema from an established relational database.
JavaScript
135
star
74

Hookd

A cli tool and visualizer for converting React class components to functional components with hooks.
TypeScript
135
star
75

kr8s

Docker/Kubernetes Visualization Tool
JavaScript
133
star
76

Svelcro

Svelte DevTool with a focus on rendering
JavaScript
133
star
77

KnightOwl

An npm package of GraphQL middleware to protect you from malicious queries.
JavaScript
133
star
78

Palaemon

Palaemon is an open-source developer tool for monitoring health and resource metrics of Kubernetes clusters and analyzing Out of Memory (OOMKill) errors
TypeScript
133
star
79

SvelTable

Feature rich data table component.
Svelte
132
star
80

Ekkremis

A periscopic view into pending Kubernetes pods
TypeScript
132
star
81

kQ

TypeScript
131
star
82

fflow

fflow is an easy-to-use open-source tool for all developers to create their React application.
JavaScript
127
star
83

KlusterView

Get instant insights on your Kubernetes clusters with our lightweight, plug-and-play performance monitoring tool
TypeScript
125
star
84

Aqls-server

An intelligent full-stack GraphQL subscription and analytics module. Server-side analytics processing, self-auditing router, and resolver plugins.
JavaScript
123
star
85

kondo

JavaScript
123
star
86

periqles

React form library for Relay and Apollo
JavaScript
120
star
87

ThermaKube

A web application that monitors the health and performance of Kubernetes clusters with support for AWS EKS deployments
JavaScript
120
star
88

arteMetrics

Creating performance monitors for Apollo implementations of graphQL.
JavaScript
118
star
89

QLens

QLens is an electron app which dynamically generates GraphQL Schemas and Mongo Schema visualization. QLens significantly cuts development time by automating the formation of their GraphQL schemas based on information fetched from their non-relational database.
JavaScript
118
star
90

firecomm

A complete framework for gRPC-node.
JavaScript
117
star
91

Kafkasocks

JavaScript
114
star
92

ReaPer

Dev tool to analyze the performance of user interface and single-page applications based on the React frontend library
JavaScript
114
star
93

AtomicKafka

JavaScript
110
star
94

Bedrock

A modular authentication library for Deno.
TypeScript
110
star
95

Docklight

Metrics for your Docker containers
TypeScript
109
star
96

Neptune

A light-weight, simple, and straightforward learning tool for your Kubernetes cluster
JavaScript
109
star
97

ArtemisQL

ArtemisQL is a GraphQL migration tool and database visualizer that empowers developers to build and implement GraphQL with ease.
TypeScript
108
star
98

shipm8

JavaScript
108
star
99

ReacTree

ReacTree - VS Code extension that generates a hierarchy tree of React components with each node listing the passed down props, indicating whether it's connected the Redux store, and guiding you to the associated file with the click of a button
TypeScript
107
star
100

reactron

Reactron is a React component visualizer that allows you to traverse an app's fiber tree and render components individually.
JavaScript
105
star