Translate mongodb-and-mongoose#16
Open
jiangyuzhen wants to merge 4 commits into
Open
Conversation
ifyour
reviewed
Jul 23, 2018
| "title": "Install and Set Up Mongoose", | ||
| "description": [ | ||
| "Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)" | ||
| "Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)", |
S1ngS1ng
suggested changes
Jul 24, 2018
| "description": [ | ||
| "Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)" | ||
| "Add mongodb and mongoose to the project’s package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)", | ||
| "在 package.json 文件中添加 mongodb 和 mongoose 依赖. 然后 require('mongoose'). 将 mLab 数据库 URI 作为 MONGO_URI 变量存储在私有 .env 文件中. 使用 mongoose.connect(<Your URI>) 命令连接数据库" |
Contributor
There was a problem hiding this comment.
mongoose.connect(<Your URI>)、require('mongoose')建议用<code></code>包上- 注意句号,要用中文的全角句号
- 结尾要加句号。下同
| "title": "Create a Model", | ||
| "description": [ | ||
| "First of all we need a Schema. Each schema maps to a MongoDB collection. It defines the shape of the documents within that collection.", | ||
| "首先,我们需要一个 Schema. 每一个 schema 对应一个 mongoDB collection 并且在那个 collection 里面定义了 documents 的模型", |
Contributor
There was a problem hiding this comment.
mongoDB 注意拼写。应为 MongoDB
| "First of all we need a Schema. Each schema maps to a MongoDB collection. It defines the shape of the documents within that collection.", | ||
| "首先,我们需要一个 Schema. 每一个 schema 对应一个 mongoDB collection 并且在那个 collection 里面定义了 documents 的模型", | ||
| "Schemas are building block for Models. They can be nested to create complex models, but in this case we’ll keep things simple.", | ||
| "Schemas 是 Models 的构建块. 它们可以嵌套来创建复杂的模型,但是这里,我们会保持简单.", |
| "A model allows you to create instances of your objects, called documents.", | ||
| "Model 可以被实例化,实例化后的对象称为 document", | ||
| "Create a person having this prototype :", | ||
| "创建一个拥有以下 prototype 的 person 对象:", |
| "Use the mongoose basic schema types. If you want you can also add", | ||
| "more fields, use simple validators like required or unique,", | ||
| "and set default values. See the <a href='http://mongoosejs.com/docs/guide.html'>mongoose docs</a>.", | ||
| "你可以使用 schema 的基础 types 去添加更多的字段。比如使用 required 或者 unique 这样的简单验证去设置默认值. 看 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a>.", |
Contributor
There was a problem hiding this comment.
感觉这里应该是 基础的 SchemaTypes
参考:http://mongoosejs.com/docs/schematypes.html#schematypes
看 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a> =>
请参考 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a>。
| "你可以使用 schema 的基础 types 去添加更多的字段。比如使用 required 或者 unique 这样的简单验证去设置默认值. 看 <a href='http://mongoosejs.com/docs/guide.html'>mongoose 文档</a>.", | ||
| "[C]RUD Part I - CREATE", | ||
| "Note: Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as done(null, data) on success, or done(err) on error.", | ||
| "注意: Glitch 是一个真实的服务, 并且通过 handler 函数和 db 进行交互. 这些函数通过一些事件去触发(e.g. 有人从终端调用了你的 API). 我们在这些联系中遵循同样的方法. 我们在完成如 nserting, searching, updating 或者 deleting 这样的异步操作后接着回调 done() 函数. 它遵循 Node 的惯例,需要在 success 时回调 done(null, data), 在 error 时回调 done(err)。", |
Contributor
There was a problem hiding this comment.
联系 => 练习 🤦♂️
注意,中文列举用顿号
done 那些,建议 <code></code> 包上
| "Note: Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as done(null, data) on success, or done(err) on error.", | ||
| "注意: Glitch 是一个真实的服务, 并且通过 handler 函数和 db 进行交互. 这些函数通过一些事件去触发(e.g. 有人从终端调用了你的 API). 我们在这些联系中遵循同样的方法. 我们在完成如 nserting, searching, updating 或者 deleting 这样的异步操作后接着回调 done() 函数. 它遵循 Node 的惯例,需要在 success 时回调 done(null, data), 在 error 时回调 done(err)。", | ||
| "Warning - When interacting with remote services, errors may occur !", | ||
| "Warning - 当与远程服务器交互时可能发生错误!", |
| "title": "Create and Save a Record of a Model", | ||
| "description": [ | ||
| "Create a document instance using the Person constructor you build before. Pass to the constructor an object having the fields name, age, and favoriteFoods. Their types must be conformant to the ones in the Person Schema. Then call the method document.save() on the returned document instance. Pass to it a callback using the Node convention. This is a common pattern, all the following CRUD methods take a callback function like this as the last argument.", | ||
| "使用 Person 的 constructor 函数可以创建一个 document 对象, 该对象包含 name, age 和 favoriteFoods 字段. 这些字段的类型必须符合 Person Schema 里面定义的类型. 然后调用 document.save(). 使用 Node 惯例传递 callback. 通常情况下,所有的 CRUD(增查改删) 方法都会像下面一样作为最后一个参数去执行一个 callback() ", |
Contributor
There was a problem hiding this comment.
constructor 有对应的翻译,构造器
建议,name、age 也用 <code></code> 包起来
S1ngS1ng
suggested changes
Jul 27, 2018
| "Use the mongoose basic schema types. If you want you can also add", | ||
| "more fields, use simple validators like required or unique,", | ||
| "and set default values. See the <a href='http://mongoosejs.com/docs/guide.html'>mongoose docs</a>.", | ||
| "你可以使用 基础的 SchemaTypes 去添加更多的字段,比如使用 required 或者 unique 这样的简单验证去设置默认值. 参考 <a href='http://mongoosejs.com/docs/guide.html'>Mongoose 文档</a>.", |
Contributor
There was a problem hiding this comment.
你可以使用 基础的 SchemaTypes 这里多了空格。“使用”之后
这句话里,句号要用全角的,你貌似忘了改了
| "[C]RUD Part I - CREATE", | ||
| "Note: Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as done(null, data) on success, or done(err) on error.", | ||
| "Warning - When interacting with remote services, errors may occur !", | ||
| "注意: Glitch 是一个真实的服务, 并且通过 handler 函数和 db 进行交互。 这些函数通过一些事件去触发(例如:有人从终端调用了你的 API), 我们在这些练习中遵循同样的方法。 比如,我们在完成 nserting、 searching、 updating 或者 deleting 这样的异步操作后接着回调 <code>done()</code> 函数。 它遵循 Node 的惯例,需要在 success 时回调 <code>done(null, data)</code>, 在 error 时回调 <code>done(err)</code>。", |
huluoyang
suggested changes
Jul 30, 2018
| "tests": [ | ||
| { | ||
| "text": "Creating and saving a db item should succeed", | ||
| "text": "成功创建一条 db 并保存。", |
| "description": [ | ||
| "Find all the people having a given name, using Model.find() -> [Person]", | ||
| "In its simplest usage, Model.find() accepts a query document (a JSON object ) as the first argument, then a callback. It returns an array of matches. It supports an extremely wide range of search options. Check it in the docs. Use the function argument personName as search key." | ||
| "使用<code>Model.find() -> [Person]</code>来查询给定名称的所有的人。", |
| "Find all the people having a given name, using Model.find() -> [Person]", | ||
| "In its simplest usage, Model.find() accepts a query document (a JSON object ) as the first argument, then a callback. It returns an array of matches. It supports an extremely wide range of search options. Check it in the docs. Use the function argument personName as search key." | ||
| "使用<code>Model.find() -> [Person]</code>来查询给定名称的所有的人。", | ||
| "最简单的用法:<code>Model.find()</code>接受一个查询的 document(一个 JSON 对象)作为第一参数,然后是回调。它将返回匹配到的项目组成的数组。这个支持极其广泛的搜索选项。使用人名作为搜索的关键词,来校验它。" |
| "tests": [ | ||
| { | ||
| "text": "Find all items corresponding to a criteria should succeed", | ||
| "text": "成功找到所有符合条件的 item(项目)。", |
| "tests": [ | ||
| { | ||
| "text": "Creating many db items at once should succeed", | ||
| "text": "应当可以一次性创建多个 item(项目)。", |
Contributor
There was a problem hiding this comment.
不能按字面意思翻译啊。
这样会不会好点:一次创建多条记录,对应 title。
Contributor
|
因为这个章节不长,建议翻译完后再 merge。 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
翻译章节
《API 与 微服务—— MongoDB 和 Mongoose》
变更文件
mongodb-and-mongoose.json
mongodb-and-mongoose.md
翻译进度
25%
0%