Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
socalledPF committed Feb 1, 2019
0 parents commit 3f0f0fa
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
39 changes: 39 additions & 0 deletions index.js
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 added model.js
Empty file.
174 changes: 174 additions & 0 deletions package-lock.json

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

15 changes: 15 additions & 0 deletions package.json
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"
}
}

0 comments on commit 3f0f0fa

Please sign in to comment.