AdditionalMappingContributions,AdditionalMappingContributor,InFlightMetadataCollector,MetadataBuildingContext
ConnectionProvider,DatabaseConnectionInfo
| const { MongoClient } = require('mongodb'); | |
| // localThresholdMS: The latency window in milliseconds (default is 15) | |
| const client = new MongoClient("mongodb://localhost:27017,localhost:27018,localhost:27019", { | |
| localThresholdMS: 15 | |
| }); | |
| client.on('topologyDescriptionChanged', (event) => { | |
| const servers = event.newDescription.servers; | |
| """ | |
| cloud_affinity_selector.py | |
| ========================== | |
| A custom PyMongo server selector that routes application traffic to mongos | |
| routers that are co-located in the same cloud provider and region as the | |
| application server. | |
| THE PROBLEM | |
| ----------- | |
| Multi-cloud Atlas sharded clusters span multiple cloud providers — for example, |
| import com.mongodb.ClientSessionOptions; | |
| import com.mongodb.client.MongoClients; | |
| import org.bson.Document; | |
| // Demonstration that it's straightforward to implement snapshot reads across sessions, | |
| // clients, and even processes | |
| public static void main() { | |
| var connectionString = "mongodb://localhost/?directConnection=false&writeConcern=majority"; | |
| // Enable snapshot reads |
| import com.mongodb.client.MongoClients; | |
| import com.mongodb.client.MongoCollection; | |
| import org.bson.BsonArray; | |
| import org.bson.BsonDocument; | |
| import org.bson.BsonInt32; | |
| import org.bson.BsonNull; | |
| import org.bson.BsonString; | |
| import org.bson.BsonValue; | |
| import org.bson.Document; | |
| import org.bson.conversions.Bson; |
| x = 5000 OR x = 6000 | |
| { | |
| "$match": { | |
| "$or": [ | |
| { | |
| "x": 5000 | |
| }, | |
| { | |
| "x": 6000 | |
| } |
| /* | |
| * Copyright (c) 2008 - 2013 10gen, Inc. <http://10gen.com> | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| /* | |
| * Copyright 2008-present MongoDB, Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| import com.mongodb.ConnectionString; | |
| import com.mongodb.MongoClientSettings; | |
| import com.mongodb.client.MongoClient; | |
| import com.mongodb.client.MongoClients; | |
| import javax.net.ssl.SSLContext; | |
| import java.security.NoSuchAlgorithmException; | |
| import java.util.function.Consumer; | |
| public class ProgrammaticMongoClientSettingsConfiguration { |
| import com.mongodb.MongoClientSettings; | |
| import com.mongodb.client.MongoClient; | |
| import com.mongodb.client.MongoClients; | |
| import com.mongodb.client.MongoCollection; | |
| import com.mongodb.client.model.Filters; | |
| import com.mongodb.client.model.Updates; | |
| import com.mongodb.event.CommandListener; | |
| import com.mongodb.event.CommandStartedEvent; | |
| import org.bson.BsonArray; | |
| import org.bson.BsonDocument; |