{"id":13800616,"url":"https://github.com/oslabs-beta/dangoDB","last_synced_at":"2025-05-13T09:31:47.141Z","repository":{"id":37350965,"uuid":"485480879","full_name":"oslabs-beta/dangoDB","owner":"oslabs-beta","description":"A MongoDB ODM for Deno","archived":false,"fork":false,"pushed_at":"2023-04-28T05:13:33.000Z","size":1103,"stargazers_count":119,"open_issues_count":4,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-07T18:08:31.072Z","etag":null,"topics":["deno","mongodb","odm"],"latest_commit_sha":null,"homepage":"https://dangodb.land/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oslabs-beta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-04-25T18:04:48.000Z","updated_at":"2025-04-26T07:09:54.000Z","dependencies_parsed_at":"2024-01-05T21:15:05.985Z","dependency_job_id":null,"html_url":"https://github.com/oslabs-beta/dangoDB","commit_stats":{"total_commits":76,"total_committers":8,"mean_commits":9.5,"dds":0.6578947368421053,"last_synced_commit":"90528aa435b17243dc1402acc3d247452571df0d"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FdangoDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FdangoDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FdangoDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FdangoDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oslabs-beta","download_url":"https://codeload.github.com/oslabs-beta/dangoDB/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931555,"owners_count":21827112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","mongodb","odm"],"created_at":"2024-08-04T00:01:14.348Z","updated_at":"2025-05-13T09:31:45.403Z","avatar_url":"https://github.com/oslabs-beta.png","language":"TypeScript","funding_links":[],"categories":["Modules"],"sub_categories":["Database"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg style=\"width: 70%\" src=\"assets/dangoDB_logo_long_midboi.png\" alt=\"dangoDB logo\"\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003edangoDB\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003eA MongoDB ODM for Deno\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\u003ca href=\"https://dangodb.land\"\u003eVisit our Website\u003c/a\u003e\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\u003ca href=\"https://medium.com/@stephen-jue/dangodb-a-mongodb-odm-for-deno-9ac46943fe54\"\u003eRead our Medium Launch Article\u003c/a\u003e\u003c/div\u003e\n\u003cbr\u003e\n\n## Table of Contents\n\n1. [Description](#description)\n2. [Getting Started](#get-started)\n3. [Query](#query)\n4. [Schema](#schema)\n5. [Authors](#authors)\n6. [License](#license)\n\n## \u003ca name=\"description\"\u003e\u003c/a\u003eDescription\n\n\u003cstrong\u003edangoDB\u003c/strong\u003e 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. \n\nIn addition, we built a user-friendly web-based [GUI](https://dangodb.land/#/schema) that auto-generates schema for users to copy and paste directly into their code. \n\n\n## \u003ca name=\"get-started\"\u003e\u003c/a\u003eGetting Started\n\nFirst, be sure that you have [Deno](https://deno.land) runtime installed and configured.\n\n### Quick Start\n\nIn your application, import the dangoDB module from the deno.land [module](https://deno.land/x/dangodb).\n\n```javascript\nimport { dango } from \"https://deno.land/x/dangodb@v1.0.2/mod.ts\";\n```\n\n### Connect to your Database\n\nNext, open a connection to your MongoDB database using your URI string.\n\n```javascript\nawait dango.connect('URI_STRING');\n\nawait dango.disconnect();\n```\n\n### Define Your Schema\n\nNow, you can define a schema and create a reference to it as illustrated below.\n\n```javascript\nconst dinosaurSchema = dango.schema(\n  {\n    name:                 // A property accepts the below options. Only type is required and must be a valid selection.\n      { \n        type: 'string',   // Valid data types listed below.\n        required: true,   // A boolean to indicate if the inserted property must have a value specified. Defaults to false.\n        unique: true,     // A boolean to indicate if the inserted property much be unique in its value in the collection. Defaults to false.\n        default: 'T-Rex', // A value to default to if none specified and required = false. Defaults to null.\n        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.\n      },\n    age: 'number',        // A property can also accept a schema value with only a type indicated.\n  }\n);\n\n/**\n*  Valid datatypes:\n*  - 'number'\n*  - 'decimal128'\n*  - 'string'\n*  - 'boolean'\n*  - 'objectid'\n*  - 'uuid'\n*  - 'date'\n*  - userSchema            // User defined schema.\n*  - array **              // In progress - Not yet implemented.\n*\n*/\n\n```\n\n### Create Your Model\n\nGreat! Now you have a schema with one property, name, which will be a 'string.' The next step is compiling our schema into a Model.\n\n```javascript\nconst Dinosaur = dango.model('Dinosaur', dinosaurSchema);\n```\n\n### Make a Query\n\nNow, let's insert a document into the Dinosaur model.\n\n```javascript\nawait Dinosaur.insertOne({ name: 'Stegosaurus' });\n```\n\nNow, 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.\n\n```javascript\nconst dinosaurs = await Dinosaur.find({ });\nconsole.log(dinosaurs); \n// [ { name: 'Triceratops', age: 70,000,000 }, { name: 'Brontosaurus', age: 150,000,000 }, { name: 'Stegosaurus', age: null }];\n```\n\nNow you've successfully inserted a document into the Dinosaur collection at your MongoDB database. \n\nCongratulations! 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\nqueried 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.\n\n\n\n## \u003ca name=\"query\"\u003e\u003c/a\u003eQuery\n\nAll queries in dangoDB are performed using models. The queries are built on the [deno_mongo](https://deno.land/x/mongo@v0.29.4) drivers. The documentation there may help guide query options. Listed below are all the query functions available in the dangoDB library.\n\n#### Create, Read, Update, Delete Operations\n\n- Model.deleteMany()\n```javascript\nModel.deleteMany()\n/**\n* @description Deletes all of the documents that match the conditions from the DB collection. It returns an object with \n* the property deletedCount, indicating how many documents were deleted. \n* @param queryObject - Query to specify which documents to delete.\n* @param options - [optional]\n* @param callback - [callback]\n* @returns object with property deletedCount, value number. \n*/\n```\n\n- Model.deleteOne()\n```javascript\nModel.deleteOne()\n/**\n* @description Deletes the first document that matches the conditions from the DB collection. It returns an object \n* with the property deletedCount, indicating how many documents were deleted. \n* @param queryObject - The query used to find matching document.\n* @param options [optional]\n* @param callback [optional]\n* @returns object with property deletedCount, value number.\n*/\n```\n- Model.find()\n```javascript\nModel.find()\n/**\n* @ description Returns all documents that satisfy the specified query criteria on the collection or view. \n* @param queryObject - The query used to find matching documents.\n* @param options - [optional] Additional options for the operation (e.g. lean, populate, projection)\n* @param callback - [optional]\n* @returns All matching documents in an array.\n*/\n```\n\n- Model.findById()\n```javascript\nModel.findById()\n/**\n* @description Returns document that matches user provided ObjectId.\n* @param queryObject - The query used to find matching document, using id.\n* @param options - [optional] - Additional options for the operation (e.g. lean, populate, projection)\n* @param callback - [optional]\n* @returns Matching document.\n*/\n```\n\n- Model.findByIdAndDelete()\n```javascript\nModel.findByIdAndDelete()\n/**\n* @description Deletes the first document that matches the id from the DB collection. It returns the document \n* with the matched property. \n* @param queryObject - The query used to find matching document, using id.\n* @param options [optional]\n* @param callback [optional]\n* @returns the deleted document.\n*/\n```\n\n- Model.findByIdAndRemove()\n```javascript\nModel.findByIdAndRemove()\n/**\n* @description Deletes the first document that matches the id from the DB collection. It returns the document \n* with the matched property. \n* @param queryObject - The query used to find matching document, using id.\n* @param options [optional]\n* @param callback [optional]\n* @returns the document matched and removed.\n*/\n```\n\n- Model.findByIdAndUpdate()\n```javascript\nModel.findByIdAndUpdate()\n/**\n* @description Updates the first document that matches the id from the DB collection. It returns the document \n* with the matched property. \n* @param filter - id used to find matching document.\n* @param replace - User document to replace matching document at database.\n* @param callback [optional]\n* @returns the document matched.\n*/\n```\n\n- Model.findOne()\n```javascript\nModel.findOne()\n/**\n* @description Returns first document that matches query.\n* @param queryObject - Query used to find matching document. \n* @param options - [optional]\n* @param callback - [optional]\n* @returns Matching document.\n*/\n```\n\n- Model.findOneAndDelete()\n```javascript\nModel.findOneAndDelete()\n/**\n* @description Deletes the first document that matches the filter from the DB collection. It returns the document \n* with the matched property. \n* @param queryObject - The query used to find matching document.\n* @param options [optional]\n* @param callback [optional]\n* @returns the deleted document.\n*/\n```\n\n- Model.findOneAndRemove()\n```javascript\nModel.findOneAndRemove()\n/**\n* @description Deletes the first document that matches the filter from the DB collection. It returns the document \n* with the matched property. \n* @param queryObject - The query used to find matching document.\n* @param options [optional]\n* @param callback [optional]\n* @returns the deleted document.\n*/\n```\n\n- Model.findOneAndReplace()\n```javascript\nModel.findOneAndReplace()\n/**\n* @description Finds a matching document, removes it, and passes in user's document. Replacement document retains same ObjectId as original document. \n* @param filter - Query used to find matching document.\n* @param replace - User document to replace matching document at database.\n* @param options - [optional]\n* @param callback - [optional]\n* @returns object displaying count for how many documents were upserted, matching, modified.\n*/\n```\n\n- Model.findOneAndUpdate()\n```javascript\nModel.findOneAndUpdate()\n/**\n* @description Updates the first document that matches filter from the DB collection. It returns the document \n* with the matched property. \n* @param filter - id used to find matching document.\n* @param replace - User document to replace matching document at database. \n* @param callback [optional]\n* @returns the document matched.\n*/\n```\n\n- Model.insertOne()\n```javascript\nModel.insertOne()\n/** \n* @description Inserts one document into database collection. \n* @param document - User provided object to be inserted into the database.\n* @returns ObjectId of inserted document.\n*/\n```\n\n- Model.insertMany()\n```javascript\nModel.insertMany()\n/**\n* @description Insert multiple documents into database. \n* @param document - Array of document(s) to be inserted into database.\n* @param options - [optional] \n* @param callback - [optional]\n* @returns documents that passed validation.\n*/\n```\n\n- Model.replaceOne()\n```javascript\nModel.replaceOne()\n/**\n* @description Finds a matching document, removes it, and passes in user's document. Replacement document retains same ObjectId as original document. \n* @param filter - Query used to find matching document.\n* @param replace - User document to replace matching document at database. \n* @param options - [optional]\n* @param callback - [optional]\n* @returns The updated object.\n*/\n```\n\n- Model.updateMany()\n```javascript\nModel.updateMany()\n/**Parameters:\n* @description Updates all documents that match queryObject. The matching fields in the DB collection will be set to the values in the updateObject.\n* @param document - query used to find document(s) to update.\n* @param update - object containing field(s) and values to set them to.\n* @param options - [optional]\n* @param callback - [optional]\n* @returns object with properties upsertedId, upsertedCount, matchedCount, modifiedCount.\n*/\n```\n\n- Model.updateOne()\n```javascript\nModel.updateOne()\n/**\n* @description Updates one document. The fields in the updateObject will be set to their respective values.\n* @param document - query used to find document to update.\n* @param update - object containing field(s) and values to set them to.\n* @param options - [optional]\n* @param callback - [optional]\n* @returns object with properties upsertedId, upsertedCount, matchedCount, modifiedCount.\n*/\n```\n\n#### Other Operations\n\n- Model.aggregate()\n```javascript\nModel.aggregate()\n/**\n* @ description Aggregation operations process multiple documents and return computed results. You can use aggregation operations to:\n* Group values from multiple documents together.\n* Perform operations on the grouped data to return a single result.\n* Analyze data changes over time.\n* @param Aggregation pipeline as an array of objects.\n* @returns Documents returned are plain javascript documents; \n*/\n```\n\n- Model.countDocuments()\n```javascript\n/**\nModel.countDocuments()\n* @description Counts number of documents matching filter in a database collection.\n* @param document - query used to find document to update. \n* @param options - [optional]\n* @param callback - [optional]\n* @returns a count (number);\n* example: query.countDocuments({ username: 'test' });\n*/\n```\n\n- Model.dropCollection()\n```javascript\nModel.dropCollection()\n/**\n* @description DropCollection drops current model/collection that user is connected to.\n* @returns undefined\n*/\n```\n\n- Model.estimatedDocumentCount()\n```javascript\nModel.estimatedDocumentCount()\n/**\n* @description Returns the count of all documents in a collection or view. The method wraps the count command.   \n* @param options - [optional]\n* @param callback - [optional]\n* @returns a count (number);\n*/\n```\n\n## \u003ca name=\"schema\"\u003e\u003c/a\u003eSchema\n\nWhen creating a schema, either a type can be assigned to each property in string format, or an object with schema options properties.\n\n#### Schema Options\n- type - Number, decimal128, string, boolean, objectid, UUID, date, object. Specified as a lowercase string.\n- required - Boolean, specifies whether a value is required in an inserted document or replacement document. \n- unique - Boolean, specifies whether a value is designated as unique for the property.\n- default - Default value if no value is provided by user. Defaults to null.\n- validator - User can provide a function test which the values to be inserted/updated need to pass before being inserted. Defaults to null.\n\nTo 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.\n\n```javascript\naddressSchema = dango.schema(\n  {\n    house_number: 'number', \n    unit: 'string', \n    street: 'string', \n    city: 'string'\n  }\n);\n\npersonSchema = dango.schema(\n  { \n    name: 'string', \n    address: addressSchema \n  }\n);\n```\n\n\n## \u003ca name=\"authors\"\u003e\u003c/a\u003eAuthors\n\n- [Bill Greco](https://github.com/wgreco13)\n- [Steve Jue](https://github.com/kaizenjoo)\n- [Celeste Knopf](https://github.com/DHolliday1881)\n- [Emilia Yoffie](https://github.com/emiliayoffie)\n\n## \u003ca name=\"license\"\u003e\u003c/a\u003eLicense\n\nThis product is licensed under the MIT License - see the LICENSE file for details.\n\nThis is an open source product.\n\nThis product is accelerated by \u003ca href=\"https://opensourcelabs.io/\"\u003eOS Labs.\u003c/a\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foslabs-beta%2FdangoDB","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foslabs-beta%2FdangoDB","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foslabs-beta%2FdangoDB/lists"}