MongoDB journey (4) Deep Learning

Source: Internet
Author: User
MongoDB Tour (4) In-depth study of Postedon ------------------------------------------------------ tips: SKU: StockkeepingUnit, minimum inventory unit. Db. categories. find ({_ id: {$ in: product [category_ids]}); db. products. renameCollection (store_produc

MongoDB Tour (4) In-depth study of Posted on ------------------------------------------------------ tips: SKU: Stock keeping Unit, minimum inventory Unit. Db. categories. find ({_ id: {$ in: product ['category _ id']}); db. products. renameCollection ("store_produc

MongoDB journey (4) deep learning about Posted on

--------------------------------------------------------

Tips:

SKU: Stock keeping Unit, U.S. server, minimum inventory Unit.

Db. categories. find ({_ id: {$ in: product ['category _ id']});

Db. products. renameCollection ("store_products ");

Db. createCollection ("users. actions", {capped: true, size: 1024 });

Db. user. actions. find (). sort ({"$ natural":-1 });

Db. system. namespaces. find (); db. system. indexes. find ();

In MongoDBV2.0, The BSON document size is limited to 16 MB. It is easy to design a good data model; performance is related.

Db. products. find ({'slug': 'Wheel-barrow-9092 '}); = like query in SQL

Db. users. find ({first_name: "Smith", age: 40}); and query

Db. users. find ({age: {$ gte: 0}, age: {$ lte: 30}); db. users. find ({age :{$ gte: 0, $ lte30 }});

--------------------------------------------------------

Others:

Set operators: $ in, $ all, $ nin;

Boolean operator: $ ne, $ not, $ or, $ and, $ exits;

The above should be enough for daily use; there are some more in-depth query methods, and we will not continue to introduce them here.

I will introduce the projection technology more:

Db. users. find ({},{ username: 1}); // The returned result contains only two fields: _ id and username;

Db. users. find ({},{ addresses: 0, payment_methods: 0}); // The returned result set object does not contain the addresses and payment_methodsfields.

Db. products. find ({},{ reviews: {$ slice: 12 }}); // the first 12 articles in the comments are returned.

Db. products. find ({},{ reviews :{$ slice:-5 }}); // The last five articles in the comments returned

Db. products. find ({},{ reviews :{$ slice: [24,12] }}); // skip the first 24 and then 12 articles

In sort,-1 is in descending order, and 1 is in ascending order.

Db. products. distinct ("tag ");

--------------------------------------------------------

Aggregate command: group function; map-reduce function;

Atomic document processing: MongoDB without transactions provides an atomic method to process the document: findAndModify command.

Db. products. update ({price: {$ lte: 10 },{$ addToSet: {tags: 'cheap '}); // basically, the update operator is the prefix, the query operator is usually an infix.

Upsert: No insert, no record filing space, update exists, limited to one record.

--------------------------------------------------------

Based on the current situation, website space, mongoDB indexing, replication, sharding, and deployment, we will not discuss it for the moment. Take a break!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.