Category Archives: MongoDB

Allow Remote Access On MongoDB

By default MongoDB doesn’t allow remote connections. MongoDB bind to local interface only, it will restrict the remote connections, besides that to allow LAN connections from Application Server open and modify your mongod.conf file like below. In this tutorial i’m using: Debian 9 Linux 64bit x64 MongoDB v4.0.2 Community Server Compute Engine on Google cloud platform Allow Remote Access On MongoDB… Read More »

Spring Data MongoDB – Upsert

In this tutorial i will share to you how to use UpSert operation in spring data mongoDB. If no document that matches the query, a new document is created by combining the query and update object. @Autowired private MongoTemplate mongoTemplate; //search a document that doesn’t exist Query query = new Query(); query.addCriteria(Criteria.where(“id”).is(“cimblo”)); Update update = new Update(); update.set(“age”,… Read More »

Spring Data MongoDB – Save Or Update

In this tutorial you will learn how to save or update data into database using spring data mongoDB. Spring Data MongoDB – Save Or Update First declare “Mongo Template”, then do save or update : @Autowired private MongoTemplate mongoTemplate; Mongo Template Save User user = new User(); user.setName(“cimblo”); user.setAge(99); //save data with save() function; Mongo Template Update… Read More »

Spring Data MongoDB LIKE Query Insensitive Case ‘%%’

With spring data mongoDB you can do “LIKE QUERY” like example below. Query query = new Query(); query.addCriteria(Criteria.where(“name”).regex(“yourString”, “i”)); mongoTemplate.find(query, CodingExample.class) Spring Data MongoDB LIKE Query Insensitive Case Spring Data MongoDB The Spring Data MongoDB project provides integration with the MongoDB document database. Key functional areas of Spring Data MongoDB are a POJO centric model for interacting with… Read More »