zoukankan      html  css  js  c++  java
  • mongodb find opearate

    new a database

    use test;
    

    show database

    show dbs;
    

    show current database

    db;
    

    delete a database

    db.dropDatabase()
    

    create a collection

    db.createCollection("movies");
    

    show all collections

    show collections;
    

    delete collection

    db.movies.drop();
    

    insert data,the parameter must be a object!!!

    db.movies.insert({name:'a',price:120});
    

    you can insert many data in one query

    db.movies.insert([{name:'b'},{name:'c'}]);
    

    when '_id' key didn't in object,save() method is same as the insert() method

    db.movies.save({name:'d'})
    

    find all data

    db.movies.find()
    

    pretty data

    db.movies.find().pretty();
    

    find one data

    db.movies.findOne();
    

    find specify flied data (name equal to a )

    db.movies.find({name:'a'});
    

    price less than 100

    db.movies.find({price:{$lt:100}})
    

    price less and equal to 100

    db.movies.find({price:{$lte:100}})
    

    g than 100

    db.movies.find({price:{$gt:100}})
    

    not equal

    db.movies.find({price:{$ne:100}})
    

    and

    db.movies..find({$and:[{name:'a'},{price:123}]})
    

    or

    db.movies.find({$or:[{name:'a'},{price:123}]})
    

    db.movies.find({price:{$gt:100},$or:[{name:'a'},{falg:true}]})
    
  • 相关阅读:
    java中的异常类
    Mysql--JDBC的基础
    eclipse使用断言
    idea中使用断言
    java的null
    array,集合(collection),集合(list)的区别
    命名管道FIFO
    标准库中的管道操作
    现代进程间的通信方式--管道
    广播编程之发送者
  • 原文地址:https://www.cnblogs.com/cyany/p/9947516.html
Copyright © 2011-2022 走看看