<commit_before>---
layout: post
title: "MongoDB"
subtitle: ""
date: 2015-7-24 12:00:00
author: "rightpeter"
---

# Update()

Reference to
[mongoDB](http://docs.mongodb.org/manual/reference/operator/update/set/)

Example:

    db.products.update(
        { _id: 100 },
        {
            {
                quantity: 500,
                details: { model: "14Q3", make: "xyz" },
                tags: [ "coats", "outerwear", "clothing" ]
            }
        }
    )
<commit_msg>Add find schema of collections<commit_after>---
layout: post
title: "MongoDB"
subtitle: ""
date: 2015-7-24 12:00:00
author: "rightpeter"
---

# Update()

Reference to
[mongoDB](http://docs.mongodb.org/manual/reference/operator/update/set/)

Example:

    db.products.update(
        { _id: 100 },
        {
            {
                quantity: 500,
                details: { model: "14Q3", make: "xyz" },
                tags: [ "coats", "outerwear", "clothing" ]
            }
        }
    )

- - - -

# Find schema of a collection in MongoDB

Reference to [Optimal.io](http://blog.optimal.io/how-to-find-the-schema-of-a-collection-in-mongodb/)

Open a mongo shell and run the following commands:

    MongoDB shell versio: x.x.x
    > show dbs
    local 0.078GB
    todo 0.xxGB
    > use todo
    switched to db todo
    > show collections
    system.indexes
    tasks
    > var scematodo = db.tasks.findOne():
    > for (var key in schematodo) { print (key) ; }
    _id
    label
    content

- - - -
{'fraction_non_alphanumeric': 0.1430490261920752, 'fraction_numerical': 0.03290799194089993, 'mean_word_length': 1.9158512720156555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2215064', 'n_tokens_mistral': 559, 'n_tokens_neox': 506, 'n_words': 116}