xuyl
V2EX  ›  Node.js

使用 mongoose 操作 mongodb, 如何在不定义 Schema 的情况下做 CRUD 操作?

  •  
  •   xuyl · Oct 21, 2018 · 3269 views
    This topic created in 2788 days ago, the information mentioned may be changed or developed.
    2 replies    2018-10-22 11:12:49 +08:00
    7anshuai
        1
    7anshuai  
       Oct 22, 2018   ❤️ 1
    可以使用 mongoose 依赖的 node-mongodb-native,例如:

    ```
    const mongoose = require('mongoose');
    const conn = mongoose.createConnection('mongodb://localhost:27017/dbname');

    const collection = conn.collection('users');
    collection.find({}).toArray((err, users) => {console.log(users)});
    ```
    songsunli
        2
    songsunli  
       Oct 22, 2018
    mongoose mongodb 教程看看 https://www.itying.com/goods-946.html
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1369 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 17:11 · PVG 01:11 · LAX 10:11 · JFK 13:11
    ♥ Do have faith in what you're doing.