Specify or change ID of a Tower model

41 views Asked by At

You are not allowed to set a specific id in the current development branch of towerjs anymore.

Do you know if there is any way to do this?

I can't seem to be able to do:

data =
  id: "123456asdasd"
  name: "Foo"

App.User.create data, (err, resource) =>
  console.log resource.get("id")
  resource.set "id", data.id
  resource.save() # doesn't work
1

There are 1 answers

0
Sebastian Hoitz On

I found the solution:

You can specify an ID like this:

data =
  id: "123456asd"
  name: "Foo"

record = App.User.build data
record.set "_id", data.id
record.save =>
  console.log record.get("id")