Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-8716: document Decimal128 in Node.js docs #1420

Merged
merged 1 commit into from Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions docs/reference/content/tutorials/crud.md
Expand Up @@ -128,6 +128,62 @@ The following example shows how to serialize a passed-in function when writing t
});
</code></pre></section>

<a name='specify-data-type'></a>
#### Specify a Data Type

The following example specifies a numerical data type
when inserting documents with the ``insertMany`` method.

{{% note %}}
The Decimal128 data type requires MongoDB server version 3.4 or higher.
{{% /note %}}

<section class="javascript5"><pre><code class="hljs">
var Long = require('mongodb').Long;
var Decimal = require('mongodb').Decimal128;

{{% myproject-connect %}}

var longValue = Long(1787);
var decimalValue = Decimal.fromString("27.8892836");

// Insert multiple documents
db.collection('numbers').insertMany([ { a : longValue }, { b : decimalValue } ], function(err, r) {
assert.equal(null, err);
assert.equal(2, r.insertedCount);
db.close();
});
});

</code></pre></section>
<section class="javascript6 hidden"><pre><code class="hljs">
var Long = require('mongodb').Long;
var Decimal = require('mongodb').Decimal128;

{{% js6-connect %}}

var longValue = Long(1787);
var decimalValue = Decimal.fromString("27.8892836");

// Insert multiple documents
var r = yield db.collection('numbers').insertMany([ { a : longValue }, { b : decimalValue } ]);
assert.equal(2, r.insertedCount);

// Close connection
db.close();
}).catch(function(err) {
console.log(err.stack);
});
</code></pre></section>

The above operation inserts the following documents into the
``numbers`` collection:

```js
{ "_id" : ObjectId("57d6f63a98724c65a5d7bd7a"), "a" : NumberLong(1787) }
{ "_id" : ObjectId("57d6f63a98724c65a5d7bd7b"), "b" : NumberDecimal("27.8892836") }
```

### Updating Documents

The ``updateOne`` and ``updateMany`` methods exist on the ``Collection`` class and are used to update and upsert documents.
Expand Down
13 changes: 12 additions & 1 deletion docs/reference/content/upgrade-migration/index.md
Expand Up @@ -7,14 +7,25 @@ title = "Upgrade Guide"
pre = "<i class='fa fa-cog'></i>"
+++

# What's New in 2.3

Key features of the 2.3 driver include:

- Implements [Decimal128](https://docs.mongodb.org), a decimal
floating-point numbering format that occupies 16 bytes (128 bits).
See the
[CRUD tutorial]({{< relref "tutorials/crud.md#specify-a-data-type" >}})
for an example.
<!-- NOTE: placeholder link to manual entry -->

# What's New in 2.2

Key features of the 2.2 driver include:

- Redesigned Connection Pool.
- Connection close will drain any outstanding operations.
- replicaSet parameter **MUST** be specified if using MongoClient to connect to replicaset, due to SDAM specification implementation.
- domain support disabled by default, enable with parameter **domainsEnabled** on MongoClient or on the Server/ReplSet/Mongos.
- Domain support disabled by default, enable with parameter **domainsEnabled** on MongoClient or on the Server/ReplSet/Mongos.

# What's New in 2.1

Expand Down