<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 問題 你想與MongoDB數據庫進行交互。 ## Solution ## 方法 ### 使用Node.js ### 安裝 * 如果你的電腦中還沒有的話請先[安裝MongoDB](http://www.mongodb.org/display/DOCS/Quickstart)?。 * [安裝MongoDB原生的模塊](https://github.com/christkv/node-mongodb-native)。 #### 保存記錄 ~~~ mongo = require 'mongodb' server = new mongo.Server "127.0.0.1", 27017, {} client = new mongo.Db 'test', server # save() updates existing records or inserts new ones as needed exampleSave = (dbErr, collection) -> console.log "Unable to access database: #{dbErr}" if dbErr collection.save { _id: "my_favorite_latte", flavor: "honeysuckle" }, (err, docs) -> console.log "Unable to save record: #{err}" if err client.close() client.open (err, database) -> client.collection 'coffeescript_example', exampleSave ~~~ #### 查找記錄 ~~~ mongo = require 'mongodb' server = new mongo.Server "127.0.0.1", 27017, {} client = new mongo.Db 'test', server exampleFind = (dbErr, collection) -> console.log "Unable to access database: #{dbErr}" if dbErr collection.find({ _id: "my_favorite_latte" }).nextObject (err, result) -> if err console.log "Unable to find record: #{err}" else console.log result # => { id: "my_favorite_latte", flavor: "honeysuckle" } client.close() client.open (err, database) -> client.collection 'coffeescript_example', exampleFind ~~~ ### 瀏覽器端 一個[基于REST的接口](https://github.com/tdegrunt/mongodb-rest)為此而生。它提供了基于AJAX的訪問方式。 ## 討論 本菜譜把_save_和_find_分成了兩個示例,目的是為了把MongoDB獨有的鏈接任務和回調管理方面的擔憂分離。[async](https://github.com/caolan/async)模塊可以幫上忙。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看