See also:
Insert¶
Medium Editor Markdown. Created with JavaScript and from Romania. Browse the code on GitHub. You know, the Medium Editor library is awesome. But there is a missing feature that some people would like to have. It's called Markdown.
- R Markdown websites are can be hosted using GitHub Pages with two additions to the standard site configuration: Add a file named.nojekyll to your site source code directory (this tells GitHub Pages to not process your site with the Jekyll engine). Change your output directory to “.” within site.yml. For example: outputdir: '.'
- Illustrate react in markdown in react. Contribute to konsumer/react-markdown-example development by creating an account on GitHub.
- The GitHub webserver observes this convention too. GitHub-flavored Markdown differs from standard Markdown. GitHub uses an extended version of Markdown. The internal linking feature is one element of many. For complete details, see the GitHub-flavored Markdown Spec technical spec. A link from within README.md to article 2.md would therefore.
- GitHub Flavored Markdown GitHub.com uses its own version of the Markdown syntax that provides an additional set of useful features, many of which make it easier to work with content on GitHub.com. Note that some features of GitHub Flavored Markdown are only available in the descriptions and comments of Issues and Pull Requests.
Records can be inserted to a collection with insert
Where
- docs is a single document object or an array of documents
- options is an options object.
- callback - callback function to run after the record is inserted.
For example
If trying to insert a record with an existing _id value, then theoperation yields in error.
Save¶
Shorthand for insert/update is save - if _id value set, therecord is updated if it exists or inserted if it does not; if the_id value is not set, then the record is inserted as a new one.
callback gets two parameters - an error object (if an error occured)and the record if it was inserted or 1 if the record was updated.
Update¶
Sample Markdown
Updates can be done with update
Where
- criteria is a query object to find records that need to beupdated (see Queries)
- update is the replacement object
- options is an options object (see below)
- callback is the callback to be run after the records are updated.Has three parameters, the first is an error object (if erroroccured), the second is the count of records that were modified, thethird is an object with the status of the operation.
Update options¶
There are several option values that can be used with an update
- multi - update all records that match the query object, defaultis false (only the first one found is updated)
- upsert - if true and no records match the query, insertupdate as a new record
- raw - driver returns updated document as bson binary Buffer,default:false
Replacement object¶
Github Markdown Color Example
If the replacement object is a document, the matching documents will bereplaced (except the _id values if no _id is set).
The example above will replace the document contents of id=123 with thereplacement object.
Github Flavored Markdown Example
To update only selected fields, $set operator needs to be used.Following replacement object replaces author value but leaves everythingelse intact.
See MongoDBdocumentation for allpossible operators.
Find and Modify¶
To update and retrieve the contents for one single record you can usefindAndModify.
Where
- criteria is the query object to find the record
- sort indicates the order of the matches if there’s more than onematching record. The first record on the result set will be used. SeeQueries->find->options->sort for the format.
- update is the replacement object
- options define the behavior of the function
- callback is the function to run after the update is done. Has twoparameters - error object (if error occured) and the record that wasupdated.
Options¶
Options object can be used for the following options:
- remove - if set to true (default is false), removes the recordfrom the collection. Callback function still gets the object but itdoesn’t exist in the collection any more.
- new - if set to true, callback function returns the modifiedrecord. Default is false (original record is returned)
- upsert - if set to true and no record matched to the query,replacement object is inserted as a new record