I am working on an angular project and I have a factory providing some global database methods. I tested this in a jsfiddle and it works, but I want to know if it is the right way to do it. 

So here's the [jsFiddle](http://jsfiddle.net/panda4man/t7qo5g4t/).

```
function DB () {
return {
    newRecord: function () {
         //create new record
        var id = 3;
        //this is the part I am wondering about
        //is it ok to use this in this way??
        this.setCurrentRecordId(id);
    },

    setCurrentRecordId: function (id) {
        alert('setting id');
         return localStorage.setItem('id', id);  
    },

    getCurrentRecordId: function () {
        return localStorage.getItem('id');
    }
}
}

var dbStuff = new DB();

dbStuff.newRecord();

alert(dbStuff.getCurrentRecordId());

```

Like I said, it seems to be working; just want to know if there is a better way or not.

Thanks!