M
M
mrsakura522021-12-07 20:46:47
Java
mrsakura52, 2021-12-07 20:46:47

How to get key value?

I get the user from the database:

Document document = Main.getPlugin(Main.class).getPlayersDataCollection().find(Filters.eq("nickname", p.getName())).first();

How to get a certain field of this document and replace it with boolean in my case?
if (document.getString()) {
    document.replace("titleOff", false);
}
if (!document.getBoolean("titleOff")) {
    document.replace("titleOff", true);
}

After which I just change the documents:
Main.getPlugin(Main.class).getPlayersDataCollection().replaceOne(Filters.eq("nickname", p.getName()), document, new UpdateOptions().upsert(true));

Document,replace doesn't work

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