MongoDB check insertion
<p>I controll data inserted or not inserted in mysql as follows</p>

<pre><code>public boolean addUser(User user) throws Exception {

    boolean isRegister=false;

    Connection conn=null;
    PreparedStatement ps=null;
    ResultSet rs=null;

    try{

        String sql="insert into users(username,email,pasword) values(?,?,?)";

        conn=dataSource.getConnection();

        ps=conn.prepareStatement(sql);

        ps.setString(1, user.getUsername());
        ps.setString(2, kullanici.getEmail());
        ps.setString(3, kullanici.getPassword());

        int success=ps.executeUpdate();

        if(success&gt;0){
            isRegister=true;
        }

        return isRegister;
    }finally{
        baglantiSonlandir(conn, null, ps);
    }


}
</code></pre>

<p>How can I achieve this process in MongoDB?
I wrote some code but I didn't achieve that data is inserted or not inserted to db.My MongoDb code is bellow;</p>

<pre><code>public boolean addUser(User user) throws Exception {

    boolean isRegister=false;

    MongoClient client=null;
    MongoDatabase database=null;

    try{

        client=new MongoClient("localhost", 27017);
        database=client.getDatabase("ogryonsis");

        MongoCollection collection=database.getCollection("users");

        Document document=new Document();
        document.put("username", user.getUserName());
        document.put("email", user.getEmail());
        document.put("password", user.getPassword());

        collection.insertOne(document);

        //int success -&gt;I didnt find for here appropriate code  

        if(success&gt;0){
            isRegister=true;
        }

        return isRegister;
    }finally{
        client.close();
    }

}
</code></pre>