`
san_yun
  • 浏览: 2651710 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

mongoDB如何query is Null

 
阅读更多

试了半天,原来通过

db.taobaoItem.find({"coupon_price":{$ne:null}}

 

MongoDB Operators

 

Query Selectors

Comparison

Name Description
$all Matches arrays that contain all elements specified in the query.
$gt Matches values that are greater than the value specified in the query.
$gte Matches values that are equal to or greater than the value specified in the query.
$in Matches any of the values that exist in an array specified in the query.
$lt Matches values that are less than the value specified in the query.
$lte Matches values that are less than or equal to the value specified in the query.
$ne Matches all values that are not equal to the value specified in the query.
$nin Matches values that do not exist in an array specified to the query.

Logical

Name Description
$or Joins query clauses with a logical OR returns all documents that match the conditions of either clause.
$and Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
$not Inverts the effect of a query expression and returns documents that do not match the query expression.
$nor Joins query clauses with a logical NOR returns all documents that fail to match both clauses.

Element

Name Description
$exists Matches documents that have the specified field.
$mod Performs a modulo operation on the value of a field and selects documents with a specified result.
$type Selects documents if a field is of the specified type.

JavaScript

Name Description
$where Matches documents that satisfy a JavaScript expression.
$regex Selects documents where values match a specified regular expression.

Geospatial

Name Description
$geoWithin Selects geometries within a bounding GeoJSON geometry.
$geoIntersects Selects geometries that intersect with a GeoJSON geometry.
$near Returns geospatial objects in proximity to a point.
$nearSphere Returns geospatial objects in proximity to a point on a sphere.

Array

Name Description
$elemMatch Selects documents if element in the array field matches all the specified $elemMatch condition.
$size Selects documents if the array field is a specified size.

Update Operators

Fields

Name Description
$inc Increments the value of the field by the specified amount.
$rename Renames a field.
$setOnInsert Sets the value of a field upon documentation creation during an upsert. Has no effect on update operations that modify existing documents.
$set Sets the value of a field in an existing document.
$unset Removes the specified field from an existing document.

Array

Operators

Name Description
$ Acts as a placeholder to update the first element that matches the query condition in an update.
$addToSet Adds elements to an existing array only if they do not already exist in the set.
$pop Removes the first or last item of an array.
$pullAll Removes multiple values from an array.
$pull Removes items from an array that match a query statement.
$pushAll Deprecated. Adds several items to an array.
$push Adds an item to an array.

Modifiers

Name Description
$each Modifies the $push and $addToSet operators to append multiple items for array updates.
$slice Modifies the $push operator to limit the size of updated arrays.
$sort Modifies the $push operator to reorder documents stored in an array.

Bitwise

Name Description
$bit Performs bitwise AND and OR updates of integer values.

Isolation

Name Description
$isolated Modifies behavior of multi-updates to improve the isolation of the operation.

Projection Operators

Name Description
$ Projects the first element in an array that matches the query condition.
$elemMatch Projects only the first element from an array that matches the specified $elemMatch condition.
$slice Limits the number of elements projected from an array. Supports skip and limit slices.

Meta-Query Operators

Query Modifiers

Name Description
$comment Adds a comment to the query to identify queries in the database profiler output.
$explain Forces MongoDB to report on query execution plans. See explain().
$hint Forces MongoDB to use a specific index. See hint()
$maxScan Limits the number of documents a cursor will return for a query. See limit().
$max Specifies a minimum exclusive upper limit for the index to use in a query. See max().
$min Specifies a minimum inclusive lower limit for the index to use in a query. See min().
$orderby Returns a cursor with documents sorted according to a sort specification. See sort().
$returnKey Forces the cursor to only return fields included in the index.
$showDiskLoc Modifies the documents returned to include references to the on-disk location of each document.
$snapshot Forces the query to use the index on the _id field. See snapshot().

Sort Order Specifier

Name Description
$natural A special sort order that orders documents using the order of documents on disk.
分享到:
评论

相关推荐

    SpringBoot整合MongoDB.docx

    Query query = new Query(Criteria.where("_id").is(id)); Update update = new Update() .set("name", updatedUser.getName()) .set("age", updatedUser.getAge()) .set("grade", updatedUser.getGrade()); ...

    mongodb与springboot集成例子

    Query query = new Query(Criteria.where("email").is(email)); return mongoTemplate.findOne(query, User.class); } ``` 通过以上步骤,你已经成功地在 Spring Boot 应用中集成了 MongoDB,并使用 `Mongo...

    java 中mongodb的各种操作查询的实例详解

    return findOne(new Query(Criteria.where("url").is(url)), PageUrl.class); } ``` 在上面的代码中,我们使用 `Criteria` 对象来构建查询条件,where 方法指定了查询字段为 "url",is 方法指定了查询值为 url。...

    mongo中模糊查询使用和QueryOperators[整理].pdf

    在MongoDB中,模糊查询和QueryOperators是进行复杂数据检索的关键工具。MongoDB是一种NoSQL数据库,它支持丰富的查询语法,允许开发者对数据进行高效、灵活的搜索。本文将详细讲解MongoDB中如何进行模糊查询以及使用...

    JAVA代码实现MongoDB动态条件之分页查询

    query.addCriteria(Criteria.where("sex").is(studentReqVO.getSex())); } if (studentReqVO.getCreateTime() != null){ query.addCriteria(Criteria.where("createTime").lte(studentReqVO.getCreateTime())); ...

    Java连接MongoDB进行增删改查的操作

    return (Company) mongoTemplate.findOne(new Query(Criteria.where("id").is(id)), entity); } ``` 与关系型数据库的连接相比 连接MongoDB与连接关系型数据库的区别在于,MongoDB使用的是NoSQL数据库,而关系型...

    分享mysql几道面试题.pdf

    判断 NULL 用 IS NULL 或者 is not null,SQL 语句函数中可以使用 ifnull () 函数来进行处理 * 无法比较 NULL 和 0;它们是不等价的 * 无法使用比较运算符来测试 NULL 值,比如 =, <, 或者 * NULL 值可以使用 <=> ...

    Mysql学习笔记

    - NULL值判断:`IS NULL`, `IS NOT NULL`。 - 逻辑运算符:`AND`, `OR`, `NOT`。 - 范围查询:`IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`。 - 模糊匹配:`LIKE`, `NOT LIKE`。 - 分页查询:`LIMIT x1, x2;`。 #...

    Oracle数据库、SQL

    - **NULL处理** SQL中的NULL表示未知,可以使用`IS NULL`或`IS NOT NULL`进行判断。 - **NVL函数** 用来处理NULL值,如 `NVL(column, default_value)`,当column为NULL时,返回default_value。 - **拼接运算符** ...

    tree-search-language:树搜索语言(TSL)是一种很棒的搜索语言

    $ ./tsl_mem -i " spec.rating is not null and author ~= 'Joe' " -o prettyjson [ { " author " : " Joe " , " spec.pages " : 100 , " spec.rating " : 4 , " title " : " Book " }, {

    程序员的SQL金典(完整版).pdf

    - 使用 `IS NULL` 或 `IS NOT NULL` 来检查空值。 - **反义运算符** - 使用 `NOT` 关键字。 - **多值检测** - 使用 `IN` 或 `NOT IN` 关键字。 - **范围值检测** - 使用 `BETWEEN` 关键字。 - **低效的...

    程序员的SQL金典.pdf 高清 下载

    - **4.2.2 空值检测**:使用IS NULL或IS NOT NULL判断某列是否为空。 - **4.2.3 反义运算符**:使用NOT关键字对逻辑表达式进行取反。 - **4.2.4 多值检测**:使用IN或NOT IN操作符判断某列的值是否在指定集合中。 - ...

Global site tag (gtag.js) - Google Analytics