Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions check/check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const mongoose = require('mongoose');
const mongoURI = 'mongodb://localhost:27017/URLs';

const connectdatabase = async function(){
try{

await mongoose.connect(mongoURI);
console.log("connect database succesfully")
} catch(err){
console.error("Error connecting to MongoDB:", err)
}
}


module.exports = connectdatabase;

16 changes: 16 additions & 0 deletions models/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const mongoose = require('mongoose');

const urlschema = new mongoose.Schema({
urlInput: {
type: String,
required:true,
},
aliasInput: {
type: String,
required:true,
}
});

const URL = mongoose.model('URL',urlschema , 'urls'); //note that if we don't name the collection with (urls) it will automatically call it "urls" beacause of lowercase and ploralize od the model name URL

module.exports = URL;
235 changes: 235 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"ejs": "^3.1.9",
"express": "^4.18.2",
"http-errors": "~1.6.3",
"mongoose": "^8.8.3",
"morgan": "~1.9.1"
},
"devDependencies": {
Expand Down
Loading