R
R
roman99662016-02-03 12:55:48
backbone.js
roman9966, 2016-02-03 12:55:48

How to delete a model from one collection to save it in another?

There is one model, let's call it "contact". There is a list of contacts, this is a collection of "contacts". There is also a history of contacts, this is a collection of "history". When a user opens a contact, that contact's model is added to the history. But when a user removes a model from the "contacts" collection, the same model is removed from the "history" collection as well. And it is necessary that it remains, to store history. Putting the "deleted" attribute on the model will not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aen, 2016-02-04
@aen

Let me guess, you are most likely passing "Contact" to "History" just by reference? In this case, both collections refer to the same model. Therefore, it is quite logical that when a model is deleted, it disappears from both collections.
You would have to transfer a copy of the model to the "History".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question