I am looking several Q&A here to understand the best way to save and perform sorting of an IP in a mongo db but I can't face up a solution. First of all: how can I save an IP? String? Int? Other? Second: Once saved (assume for example that my Ips go to 10.1.0.20 to 10.1.1.255), I have to get the "highest" IP in my DB and increment the new one by 1. How can I do that? I mean, what is the best way to retrieve it? Is it correct to perfrom
this.model.findOne().sort({"staticIp": -1}).exec();