-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
29 changed files
with
337 additions
and
3 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
// 描述数据的格式 text json xml | ||
|
||
|
||
|
||
var students=[ | ||
{name:"xiaozhang",age:21,sex:0}, | ||
{name:"xiaozhang",age:21,sex:0}, | ||
{name:"xiaoA",age:23,sex:1} | ||
]; | ||
|
||
|
||
|
||
<students> | ||
<student sex="0"> | ||
<name>小张</name> | ||
<age>21</age> | ||
</student> | ||
<student></student> | ||
<student></student> | ||
|
||
</students> | ||
|
||
|
||
</body> | ||
</html> |
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,49 @@ | ||
|
||
var Student =require("./model/Student"); | ||
|
||
//添加数据 | ||
/*var wujian=new Student({name:"wujian",age:31,sex:"男"}); | ||
var liuziun=new Student({name:"liu",age:21,sex:"女"}); | ||
var xuxiangke=new Student({name:"xu",age:11,sex:"男"}); | ||
wujian.save(); | ||
liuziun.save(); | ||
xuxiangke.save();*/ | ||
|
||
|
||
//查询数据 | ||
/*Student.find(function (err, students) { | ||
if (err) return console.error(err); | ||
console.log(students); | ||
}); | ||
Student.find({ name: "liu" }, function (err, students) { | ||
if (err) return console.error(err); | ||
console.log(students); | ||
}); | ||
Student.findByName("liu",function(err,data){ | ||
console.log(data); | ||
}); | ||
*/ | ||
|
||
//修改数据 | ||
/*Student.update({ age: { $gt: 20 } }, { age: 25 }, {multi: true }, function(err){ | ||
if (err) return console.error(err); | ||
console.log("修改成功"); | ||
});*/ | ||
|
||
//删除数据 | ||
Student.remove({ _id: '59f161f7154ae10fd427bb70' }, function (err) { | ||
if (err) return handleError(err); | ||
console.log("removed!"); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,19 @@ | ||
var mongoose = require('mongoose'); | ||
mongoose.connect('mongodb://localhost/student', { useMongoClient: true }); | ||
mongoose.Promise = global.Promise; | ||
|
||
var studentSchema = mongoose.Schema({ | ||
name: String, | ||
age:Number, | ||
sex:String | ||
}); | ||
|
||
studentSchema.statics.findByName = function(name, cb) { | ||
return this.find({ name: new RegExp(name, 'i') }, cb); | ||
}; | ||
|
||
var Student = mongoose.model('Student', studentSchema); | ||
|
||
|
||
module.exports=Student; | ||
|
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": "0705", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"mongoose": "^4.12.4" | ||
} | ||
} |