-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3f0f0fa
Showing
5 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const mongoose = require('mongoose') | ||
|
||
// const dbUrl = 'mongodb://fery:[email protected]:55587/idphoto' | ||
const dbUrl = 'mongodb://fery:[email protected]:55587/idphoto' | ||
|
||
mongoose.connect(dbUrl) | ||
const db = mongoose.connection | ||
db.once('open', () => { | ||
console.log('connected') | ||
}) | ||
|
||
const kittySchema = new mongoose.Schema({ | ||
name: String | ||
}) | ||
|
||
|
||
|
||
kittySchema.methods.speak = function () { | ||
const greeting = this.name ? 'Mewo name is ' + this.name : "I don't have a name" | ||
console.log(greeting) | ||
} | ||
|
||
const Kitten = mongoose.model('Kitten', kittySchema) | ||
|
||
// const fluffy = new Kitten({ name: 'fluffy1'}) | ||
|
||
// fluffy.save(function(err, fluffy) { | ||
// if (err) return console.log(err) | ||
// console.log(fluffy) | ||
// fluffy.speak() | ||
// }) | ||
// Kitten.findOne(function(err, kittens) { | ||
// if (err) return console.log(err) | ||
// console.log(kittens) | ||
// }) | ||
Kitten.updateOne({name: 'fluffy'}, { name: 'kitty'},function(err, res) { | ||
if (err) throw err | ||
console.log(res) | ||
}) |
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "learn-mongodb", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"mongoose": "^5.4.1" | ||
} | ||
} |