F
F
fife2021-08-25 18:01:19
Java
fife, 2021-08-25 18:01:19

How to overwrite in mongodb without fetch query?

There is

Criteria typeCriteria = Criteria.where("type").is(Type));//type один из вариантов с enum`a

        Query query = new Query();
        query.addCriteria(typeCriteria);


        mongo.findAndReplace(query,state,bdname); 

//хотелось бы заменить на просто mongo.save(state, bdname)


There is only one entry in the database for each enum value.

I would like this enum value to be something like an ID, and when trying to save, it first looks to see if there is already such a type. If there is, overwritten, if not, then just save.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question