Help with UserMangement tickets

Hello,

I’m having a bit of trouble on how to do the ticket consistenting: userMangement. I am not sure how to implement the different userSessions that are required from us to complete this sections. Could someone point me in the right direction?

Thanks

The starting point is:

private final MongoCollection sessionsCollection;

Above you will replace Document with Session. A Document is general and can be used for any collection while the Session object is specific to the sessions collection and uses
the “pojo” technique described in lecture. The Session object has normal Java getter’s and setter’s.

You already have an example in UserDao.java of how to handle pojo with the users collection and the User object.

private final MongoCollection usersCollection;

Look at the users collection code concerning the pojo code registry as an example to follow.

Once you change sessions to use pojo then sessionsCollection.find() returns an instance of Session and insert takes an instance of Session.

If you get stuck trying to use a pojo technique for some of the ticket items you could fall back to using the Document class. For example I did that in the deleteUser method. I used Document in Java to “imitate” the MongoDB shell commands I was familiar with,
like db.users.deleteOne({“email” : email}). In the shell deleteOne takes a document which can be imitated using a new Document in Java.

2 Likes