zoukankan      html  css  js  c++  java
  • MongoDB数据类型

    对象ID:
    ObjectId id = new ObjectId();
    ObjectId copy = new ObjectId(id);
    正则表达式:
    Pattern john = Pattern.compile("joh?n", CASE_INSENSITIVE);
    BasicDBObject query = new BasicDBObject("name", john);

    // finds all people with "name" matching /joh?n/i
    DBCursor cursor = collection.find(query);
    数据库引用:
    DBRef addressRef = new DBRef(db, "foo.bar", address_id);
    DBObject address = addressRef.fetch();

    DBObject person = BasicDBObjectBuilder.start()
    .add("name", "Fred")
    .add("address", addressRef)
    .get();
    collection.save(person);

    DBObject fred = collection.findOne();
    DBRef addressObj = (DBRef)fred.get("address");
    addressObj.fetch()

    二进制数据:
    byte[]

    嵌入式文档:
    {
    "x" : {
    "y" : 3
    }
    }
    BasicDBObject y = new BasicDBObject("y", 3);
    BasicDBObject x = new BasicDBObject("x", y);

    数组:
    {
    "x" : [
    1,
    2,
    {"foo" : "bar"},
    4
    ]
    }
    ArrayList x = new ArrayList();
    x.add(1);
    x.add(2);
    x.add(new BasicDBObject("foo", "bar"));
    x.add(4);

    BasicDBObject doc = new BasicDBObject("x", x);



  • 相关阅读:
    eclipse 不自动提示和Alt + / 没提示和eclipse增强代码提示
    uboot 添加命令
    ps and kill command
    C 类型volatile 的作用
    git tutorial
    python 与命令
    C++ new and delete
    Glade3 tutorial in chinese
    查找IP与MAC
    ns3 无线资料
  • 原文地址:https://www.cnblogs.com/macula7/p/1960392.html
Copyright © 2011-2022 走看看