From a3e8819be47d0751e7ba758dbd39aabcfd9dd8f7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 6 Oct 2024 18:22:05 +0000 Subject: [PATCH 1/2] 3.0.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6f830a7..5baa9f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "backend-generator-cli", - "version": "3.0.3", + "version": "3.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "backend-generator-cli", - "version": "3.0.3", + "version": "3.0.4", "license": "MIT", "dependencies": { "@google/generative-ai": "^0.17.1", diff --git a/package.json b/package.json index c1fdae8..e5a06d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend-generator-cli", - "version": "3.0.3", + "version": "3.0.4", "main": "index.js", "type": "module", "bin": { From d6fc6cedf3fa60a503eef05b4c4368e0dbe140cb Mon Sep 17 00:00:00 2001 From: partg952 Date: Tue, 8 Oct 2024 17:50:08 +0530 Subject: [PATCH 2/2] added mongoose schema and mongoose connection snippets --- README.md | 35 +++++++++++++++++++++++++++++++++++ snippets/mongoose-con.js | 10 ++++++++++ snippets/mongoose-schema.js | 9 +++++++++ 3 files changed, 54 insertions(+) create mode 100644 snippets/mongoose-con.js create mode 100644 snippets/mongoose-schema.js diff --git a/README.md b/README.md index d4975bd..d19a84b 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,41 @@ This command will create a new file `multer-file-upload.js` in the current worki export const upload = multer({ storage }); ``` +5. **`mongoose-con`**: + Sets up a connection to your mongodb using `mongoose`. + + **Code Snippet**: + ```js + import mongoose from 'mongoose'; + + function connectToDB(URI) { + mongoose.connect(URI).then(() => { + console.log("Connection to the db succesful"); + }).catch(err => { + console.error("An error occcured : ",err); + }) + } + export default connectToDB; + + + ``` +6. **`mongoose-schema`**: + Sets up a basic schema for your db using `mongoose`. + + **Code Snippet**: + ```js + import mongoose from 'mongoose'; + + const schema = new mongoose.Schema({ + key:String, + }); + + const model = mongoose.model("Model",schema); + + export default model; + + ``` + ### 3. `run generate-ai-snippet ` With the new AI-powered code generation feature, you can generate customized code snippets. For instance, to generate a code snippet for a specific backend functionality, you can run: diff --git a/snippets/mongoose-con.js b/snippets/mongoose-con.js new file mode 100644 index 0000000..7fc0e09 --- /dev/null +++ b/snippets/mongoose-con.js @@ -0,0 +1,10 @@ +import mongoose from 'mongoose'; + +function connectToDB(URI) { + mongoose.connect(URI).then(() => { + console.log("Connection to the db succesful"); + }).catch(err => { + console.error("An error occcured : ",err); + }) +} +export default connectToDB; diff --git a/snippets/mongoose-schema.js b/snippets/mongoose-schema.js new file mode 100644 index 0000000..8b2b5be --- /dev/null +++ b/snippets/mongoose-schema.js @@ -0,0 +1,9 @@ +import mongoose from 'mongoose'; + +const schema = new mongoose.Schema({ + key:String, +}); + +const model = mongoose.model("Model",schema); + +export default model; \ No newline at end of file