cayasso/oomvc — Issue #22: How do I completely clear the local DB?
Author: noctivityinc
Created: 2011-10-31 01:05:57+00:00
State: open

I'm finding that I have a need to clear the DB for an object and start clean. For example, in dimensions if the user decides to change the shape of their room from rectangle to l-shaped I need to start from scratch with the space object being blank.

Here is an example:

```
var Room = new Lowes.My.Model.Room('rooms');
var Line = new Lowes.My.Model.Line('lines');
var Element = new Lowes.My.Model.Element('elements');

$('#select_a_shape').select(function()
Room.new_or_update(spaceID, {type: $(this).val()}, function (res) {
if(res.ok) {
room = res.room;
deleteLinesForSpace(room);
deleteElementsForSpace(room);
}
});
});
```

As you can see from the above, when the user selects a new shape from the pulldown menu I update the room's shape and then delete the lines from the DB but unfortunately all previous lines and elements for room still exist in the **local** database. I realize that when you fix the instance level destroy I could use that but, to be safe, I'd simply like to "clear" the local database entirely and start clean.

I thought that by doing something like:
var Room = new Lowes.My.Model.Room('rooms');

before calling Room.update would give me a new object, but it doesn't seem to do anything. How can I do this?