MongoDB/devcenter-articles huggingface dataset:
# Halting Development on MongoDB Swift Driver

MongoDB is halting development on our server-side Swift driver. We remain excited about Swift and will continue our development of our mobile Swift SDK.

We released our server-side Swift driver in 2020 as an open source project and are incredibly proud of the work that our engineering team has contributed to the Swift community over the last four years. Unfortunately, today we are announcing our decision to stop development of the MongoDB server-side Swift driver. We understand that this news may come as a disappointment to the community of current users.

There are still ways to use MongoDB with Swift:

 - Use the MongoDB driver with server-side Swift applications as is 
 - Use the MongoDB C Driver directly in your server-side Swift projects
 - Usage of another community Swift driver, mongokitten

Community members and developers are welcome to fork our existing driver and add features as you see fit - the Swift driver is under the Apache 2.0 license and source code is available on GitHub. For those developing client/mobile applications, MongoDB offers the Realm Swift SDK with real time sync to MongoDB Atlas.

We would like to take this opportunity to express our heartfelt appreciation for the enthusiastic support that the Swift community has shown for MongoDB. Your loyalty and feedback have been invaluable to us throughout our journey, and we hope to resume development on the server-side Swift driver in the future.
# Leafsteroid Resources

 
Leafsteroids is a MongoDB Demo showing the following services and integrations
------------------------------------------------------------------------

**Atlas App Services**  
All in one backend. Atlas App Services offers a full-blown REST service using Atlas Functions and HTTPS endpoints.  

**Atlas Search**  
Used to find the player nickname in the Web UI. 

**Atlas Charts**  
Event & personalized player dashboards accessible over the web. Built-in visualization right with your data. No additional tools required. 

**Document Model**  
Every game run is a single document demonstrating rich documents and “data that works together lives together”, while other data entities are simple collections (configuration). 

**AWS Beanstalk** Hosts the Blazor Server Application (website). 

**AWS EC2**  
Used internally by AWS Beanstalk. Used to host our Python game server. 

**AWS S3** 
Used internally by AWS Beanstalk. 

**AWS Private Cloud**  
Private VPN connection between AWS and MongoDB. 

  

**At a MongoDB .local Event and want to register to play Leafsteroids? Register Here**

You can build & play Leafsteroids yourself with the following links

## Development Resources 
|Resource| Link|
|---|---|
|Github Repo |Here|
|MongoDB TV Livestream
|Here|
|MongoDB & AWS |Here|
|MongoDB on the AWS Marketplace
|Here|
# Quick Start: BSON Data Types - Date

    

Dates and times in programming can be a challenge. Which Time Zone is the event happening in? What date format is being used? Is it `MM/DD/YYYY` or `DD/MM/YYYY`? Settling on a standard is important for data storage and then again when displaying the date and time. The recommended way to store dates in MongoDB is to use the BSON Date data type.

The BSON Specification refers to the `Date` type as the *UTC datetime* and is a 64-bit integer. It represents the number of milliseconds since the Unix epoch, which was 00:00:00 UTC on 1 January 1970. This provides a lot of flexibilty in past and future dates. With a 64-bit integer in use, we are able to represent dates *roughly* 290 million years before and after the epoch. As a signed 64-bit integer we are able to represent dates *prior* to 1 Jan 1970 with a negative number and positive numbers represent dates *after* 1 Jan 1970.

## Why & Where to Use

You'll want to use the `Date` data type whenever you need to store date and/or time values in MongoDB. You may have seen a `timestamp` data type as well and thought "Oh, that's what I need." However, the `timestamp` data type should be left for **internal** usage in MongoDB. The `Date` type is the data type we'll want to use for application development.

## How to Use

There are some benefits to using the `Date` data type in that it comes with some handy features and methods. Need to assign a `Date` type to a variable? We have you covered there:

``` javascript
var newDate = new Date();
```

What did that create exactly?

``` none
> newDate;
ISODate("2020-05-11T20:14:14.796Z")
```

Very nice, we have a date and time wrapped as an ISODate. If we need that printed in a `string` format, we can use the `toString()` method.

``` none
> newDate.toString();
Mon May 11 2020 13:14:14 GMT-0700 (Pacific Daylight Time)
```

## Wrap Up

>Get started exploring BSON types, like Date, with MongoDB Atlas today!

The `date` field is the recommended data type to use when you want to store date and time information in MongoDB. It provides the flexibility to store date and time values in a consistent format that can easily be stored and retrieved by your application. Give the BSON `Date` data type a try for your applications.
# Document Enrichment and Schema Updates

So your business needs have changed and there’s additional data that needs to be stored within an existing dataset. Fear not! With MongoDB, this is no sweat.

> In this article, I’ll show you how to quickly add and populate additional fields into an existing database collection.

## The Scenario

Let’s say you have a “Netflix” type application and you want to allow users to see which movies they have watched. We’ll use the sample\_mflix database from the sample datasets available in a MongoDB Atlas cluster.

Here is the existing schema for the user collection in the sample\_mflix database:

``` js
{
    _id: ObjectId(),
    name: ,
    email: ,
    password: 
}
```

## The Solution

There are a few ways we could go about this. Since MongoDB has a flexible data model, we can just add our new data into existing documents.

In this example, we are going to assume that we know the user ID. We’ll use `updateOne` and the `$addToSet` operator to add our new data.

``` js
const { db } = await connectToDatabase();
const collection = await db.collection(“users”).updateOne(
    { _id: ObjectID(“59b99db9cfa9a34dcd7885bf”) },
    {
        $addToSet: {
            moviesWatched: {
                ,
                ,
                <poster>
            }
        }
    }
);
```

The `$addToSet` operator adds a value to an array avoiding duplicates. If the field referenced is not present in the document, `$addToSet` will create the array field and enter the specified value. If the value is already present in the field, `$addToSet` will do nothing.

Using `$addToSet` will prevent us from duplicating movies when they are watched multiple times.

## The Result

Now, when a user goes to their profile, they will see their watched movies.

But what if the user has not watched any movies? The user will simply not have that field in their document.

I’m using Next.js for this application. I simply need to check to see if a user has watched any movies and display the appropriate information accordingly.

``` js
{ moviesWatched
    ? "Movies I've Watched"
    : "I have not watched any movies yet :("
}
```

## Conclusion

Because of MongoDB’s flexible data model, we can have multiple schemas in one collection. This allows you to easily update data and fields in existing schemas.

If you would like to learn more about schema validation, take a look at the Schema Validation documentation.

I’d love to hear your feedback or questions. Let’s chat in the MongoDB Community.
# Using AWS Rekognition to Analyse and Tag Uploaded Images

>Please note: This article discusses Stitch. Stitch is now MongoDB Realm. All the same features and functionality, now with a new name. Learn more here. We will be updating this article in due course.

Computers can now look at a video or image and know what's going on and, sometimes, who's in it. Amazon Web Service Rekognition gives your applications the eyes it needs to label visual content. In the following, you can see how to use Rekognition along with MongoDB Stitch to supplement new content with information as it is inserted into the database.

You can easily detect labels or faces in images or videos in your MongoDB application using the built-in AWS service. Just add the AWS service and use the Stitch client to execute the AWS SES request right from your React.js application or create a Stitch function and Trigger. In a recent Stitchcraft live coding session on my Twitch channel, I wanted to tag an image using label detection. I set up a trigger that executed a function after an image was uploaded to my S3 bucket and its metadata was inserted into a collection.

``` javascript
exports = function(changeEvent) {
  const aws = context.services.get('AWS');
  const mongodb = context.services.get("mongodb-atlas");
  const insertedPic = changeEvent.fullDocument;

  const args = {
    Image: {
      S3Object: {
        Bucket: insertedPic.s3.bucket,
        Name: insertedPic.s3.key
      }
    },
    MaxLabels: 10,
    MinConfidence: 75.0
  };

  return aws.rekognition()
    .DetectLabels(args)
    .then(result => {
      return mongodb
        .db('data')
        .collection('picstream')
        .updateOne({_id: insertedPic._id}, {$set: {tags: result.Labels}});
    });
};
```

With just a couple of service calls, I was able to take an image, stored in S3, analyse it with Rekognition, and add the tags to its document. Want to see how it all came together? Watch the recording on YouTube with the Github repo in the description. Follow me on Twitch to join me and ask questions live.

✅ Already have an AWS account? Atlas supports paying for usage via the AWS Marketplace (AWS MP) without any upfront commitment — simply sign up for MongoDB Atlas via AWS Marketplace.
# Getting Your Free MongoDB Atlas Cluster

**You probably already know that MongoDB Atlas is MongoDB as a service in the public cloud of your choice but did you know we also offer a free forever cluster? In this Quick Start, we'll show you why you should get one and how to create one.**

MongoDB Atlas's Free Tier clusters - which are also known as M0 Sandboxes - are limited to only 512MB of storage but it's more than enough for a pet project or to learn about MongoDB with our free MongoDB University courses.

The only restriction on them is that they are available in a few regions for each of our three cloud providers: currently there are six on AWS, five on Azure, and four on Google Cloud Platform.

In this tutorial video, I will show you how to create an account. Then I'll show you how to create your first 3 node cluster and populate it with sample data.

:youtube]{vid=rPqRyYJmx2g}

Now that you understand the basics of [MongoDB Atlas, you may want to explore some of our advanced features that are not available in the Free Tier clusters:

-   Peering your MongoDB Clusters with your AWS, GCP or Azure machines is only available for dedicated instances (M10 at least),
-   LDAP Authentication and Authorization,
-   AWS PrivateLink.

Our new Lucene-based Full-Text Search engine is now available for free tier clusters directly.
# Capture IoT Data With MongoDB in 5 Minutes

> Please note: This article discusses Stitch. Stitch is now MongoDB Realm. All the same features and functionality, now with a new name. Learn more here. We will be updating this article in due course.

Capturing IoT (Internet of Things) data is a complex task for 2 main reasons:

-   We have to deal with a huge amount of data so we need a rock solid
    architecture.
-   While keeping a bulletproof security level.

First, let's have a look at a standard IoT capture architecture:

On the left, we have our sensors. Let's assume they can push data every
second over TCP using a
POST) and let's suppose we
have a million of them. We need an architecture capable to handle a
million queries per seconds and able to resist any kind of network or
hardware failure. TCP queries need to be distributed evenly to the
application servers using load
balancers) and
finally, the application servers are able to push the data to our
multiple
Mongos
routers from our MongoDB Sharded
Cluster.

As you can see, this architecture is relatively complex to install. We
need to:

-   buy and maintain a lot of servers,
-   make security updates on a regular basis of the Operating Systems
    and applications,
-   have an auto-scaling capability (reduce maintenance cost & enable
    automatic failover).

This kind of architecture is expensive and maintenance cost can be quite
high as well.

Now let's solve this same problem with MongoDB Stitch!

Once you have created a MongoDB Atlas
cluster, you can attach a
MongoDB Stitch application to it
and then create an HTTP
Service
containing the following code:

``` javascript
exports = function(payload, response) {
  const mongodb = context.services.get("mongodb-atlas");
  const sensors = mongodb.db("stitch").collection("sensors");
  var body = EJSON.parse(payload.body.text());
  body.createdAt = new Date();
  sensors.insertOne(body)
  .then(result => {
    response.setStatusCode(201);
  });
};
```

And that's it! That's all we need! Our HTTP POST service can be reached
directly by the sensors from the webhook provided by MongoDB Stitch like
so:

``` bash
curl -H "Content-Type: application/json" -d '{"temp":22.4}' https://webhooks.mongodb-stitch.com/api/client/v2.0/app/stitchtapp-abcde/service/sensors/incoming_webhook/post_sensor?secret=test
```

Because MongoDB Stitch is capable of scaling automatically according to
demand, you no longer have to take care of infrastructure or handling
failovers.

## Next Step

Thanks for taking the time to read my post. I hope you found it useful
and interesting.

If you are looking for a very simple way to get started with MongoDB,
you can do that in just 5 clicks on our MongoDB
Atlas database service in the
cloud.

You can also try MongoDB Stitch for
free and discover how the
billing works.

If you want to query your data sitting in MongoDB Atlas using MongoDB
Stitch, I recommend this article from Michael
Lynn.
# Realm Kotlin 0.6.0.

  
  
Realm Kotlin 0.6.0  
==================  
  
We just released v0.6.0 of Realm Kotlin. It contains support for Kotlin/JVM, indexed fields as well as a number of bug fixes.  

> **Build better mobile apps with Atlas Device Sync**: Atlas Device Sync is a fully-managed mobile backend-as-a-service. Leverage out-of-the-box infrastructure, data synchronization capabilities, built-in network handling, and much more to quickly launch enterprise-grade mobile apps. Get started now by build: Deploy Sample for Free!
  
Kotlin/JVM support  
==================  
  
The new Realm Kotlin SDK was designed from its inception to support Multiplatform. So far, we’ve been focusing on KMM targets i.e Android and iOS but there was a push from the community to add JVM support, this is now possible using 0.6.0 by enabling the following DSL into your project:  
  
```  
kotlin { jvm() // other targets …}  

```  
  
Now your app can target:  
  
Android, iOS, macOS and JVM (Linux _since Centos 7_, macOS _x86\_64_ and Windows _8.1 64_).  
  
What to build with Kotlin/JVM?  
==============================  
  
*   You can build desktop applications using Compose Desktop (see examples: MultiplatformDemo and FantasyPremierLeague).  
*   You can build a classic Java console application (see JVMConsole).  
*   You can run your Android tests on JVM (note there’s a current issue on IntelliJ where the execution of Android tests from the common source-set is not possible, see/upvote :) https://youtrack.jetbrains.com/issue/KTIJ-15152, alternatively you can still run them as a Gradle task).  
  
Where is it installed?  
======================  
  
The native library dependency is extracted from the cinterop-jar and installed into a default location on your machine:  
  
*   _Linux_:  
  
```  
$HOME/.cache/io.realm.kotlin/  

```  
  
*   _macOS:_  
  
```  
$HOME/Library/Caches/io.realm.kotlin/  

```  
  
*   _Windows:_  
  
```  
%localappdata%\io-realm-kotlin\  

```  
  
Support Indexed fields  
======================  
  
To index a field, use the _@Index_ annotation. Like primary keys, this makes writes slightly slower, but makes reads faster. It’s best to only add indexes when you’re optimizing the read performance for specific situations.  
  
Abstracted public API into interfaces  
=====================================  
  
If you tried out the previous version, you will notice that we did an internal refactoring of the project in order to make public APIs consumable via interfaces instead of classes (ex: Realm and RealmConfiguration), this should increase decoupling and make mocking and testability easier for developers.  
  
🎉 Thanks for reading. Now go forth and build amazing apps with Realm! As always, we’re around on GitHub, Twitter and #realm channel on the official Kotlin Slack.  
  
See the full changelog for all the details.
HOME!

    
      
          
              MongoBnB
          
      
      
      {% for property in response %}
        
            
            
                {{ property.name }} (Up to {{ property.guests }} guests)
                

{{ property.address }}

                
                    {{ property.summary }}
                

            

            
                ${{ property.price }}/night (+${{ property.cleaning_fee }} Cleaning Fee)
            

            
                Details
                Book
            
        
      {% endfor %}
      
    

    
        
            
                MongoBnB
                Back
            
        
        

    
        
        
            {{ property.name }} (Up to {{ property.guests }} guests)
            

{{ property.address }}

            
                {{ property.summary }}
            

        
        
            {% for amenity in property.amenities %}
            {{ amenity }}
            {% endfor %}
        

        
            ${{ property.price }}/night (+${{ property.cleaning_fee }} Cleaning Fee)
        

        
            Book
        
    
        
    

    
        
            
                MongoBnB
                Back
            
        
        

    
        
            Confirmed!
            

Your booking confirmation for {{request.path_params['id']}} is {{confirmation}}
# Storing Large Objects and Files in MongoDB

Large objects, or "files", are easily stored in MongoDB. It is no problem to store 100MB videos in the database.

This has a number of advantages over files stored in a file system. Unlike a file system, the database will have no problem dealing with millions of objects. Additionally, we get the power of the database when dealing with this data: we can do advanced queries to find a file, using indexes; we can also do neat things like replication of the entire file set.

MongoDB stores objects in a binary format called BSON. BinData is a BSON data type for a binary byte array. However, MongoDB objects are typically limited to 16MB in size. To deal with this, files are "chunked" into multiple objects that are less than 255 KiB each. This has the added advantage of letting us efficiently retrieve a specific range of the given file.

While we could write our own chunking code, a standard format for this chunking is predefined, called GridFS. GridFS support is included in all official MongoDB drivers and also in the mongofiles command line utility.

A good way to do a quick test of this facility is to try out the mongofiles utility. See the MongoDB documentation for more information on GridFS.

## More Information

-   GridFS Docs
-   Building MongoDB Applications with Binary Files Using GridFS: Part 1
-   Building MongoDB Applications with Binary Files Using GridFS: Part 2
-   MongoDB Architecture Guide
# MongoDB.Live 2020 Keynote In Less Than 10 Minutes

Didn't get a chance to attend the MongoDB.Live 2020 online conference
this year? Don't worry. We have compiled a quick recap of all the
highlights to get you caught up.

>
>
>MongoDB.Live 2020 - Everything from the Breakthroughs to the
>Milestones - in 10 Minutes!
>
>:youtube]{vid=TB_EdovmBUo}
>
>

As you can see, we packed a lot of exciting news in this year's event.

MongoDB Realm:  
-   Bi-directional sync between mobile devices and data in an Atlas
    cluster
-   Easy integration with authentication, serverless functions and
    triggers
-   GraphQL support

MongoDB Server 4.4:  
-   Refinable shard keys
-   Hedged reads
-   New query language additions - union, custom aggregation expressions

MongoDB Atlas:  
-   Atlas Search GA
-   Atlas Online Archive (Beta)
-   Automated schema suggestions
-   AWS IAM authentication

Analytics  
-   Atlas Data Lake
-   Federated queries
-   Charts embedding SDK

DevOps Tools and Integrations  
-   Community Kubernetes operator and containerized Ops Manager for
    Enterprise
-   New MongoDB shell
-   New integration for VS Code and other JetBrains IDEs

MongoDB Learning & Community  
-   University Learning Paths
-   Developer Hub
-   Community Forum

Over 14,000 attendees attended our annual user conference online to
experience how we make data stunningly easy to work with. If you didn't
get the chance to attend, check out our upcoming [MongoDB.live 2020
regional series. These virtual
conferences in every corner of the globe are the easiest way for you to
sharpen your skills during a full day of interactive, virtual sessions,
deep dives, and workshops from the comfort of your home and the
convenience of your time zone. You'll discover new ways MongoDB removes
the developer pain of working with data, allowing you to focus on your
vision and freeing your genius.

To learn more, ask questions, leave feedback or simply connect with
other MongoDB developers, visit our community
forums. Come to learn.
Stay to connect.

>
>
>Get started with Atlas is easy. Sign up for a free MongoDB
>Atlas account to start working with
>all the exciting new features of MongoDB, including Realm and Charts,
>today!
>
>
# Anonytexts

## Creators
Maryam Mudashiru and Idris Aweda Zubair contributed this project.

## About the Project

Anonytexts lets you message friends and family completely anonymously. Pull a prank with your friends or send your loved one a secret message.

## Inspiration

It's quite a popular way to have fun amongst students in Nigeria to create profiles on anonymous messaging platforms to be shared amongst their peers so they may speak their minds.

Being a student, and having used a couple of these, most of them don't make it as easy and fun as it should be.

## Why MongoDB?

We wanted to stand out by adding giving users more flexibility and customization while also considering the effects in the long run. We needed a database with a flexible structure that allows for scalability with zero deployment issues. MongoDB Atlas was the best bet.

## How It Works

You create an account on the platform, with just your name, email and password. You choose to set a username or not. You get access to your dashboard where you can share your unique link to friends. People message you completely anonymously, leaving you to have to figure out which message is from which person. You may reply messages from users who have an account on the platform too.