Lost data after save in other client

I have a page that displays a list of data.
The data model is built with SuperMap.
After save synchronized with socket for events.
I get the list with a method in the ViewModel.
This method allows me to filter the data.

Stage: (Work with 2 browser)

  1. Browser 1: show list - ok
  2. Browser 2: show list - ok
  3. Browser 1: change and save data - ok
  4. browser 2: LOSE modified record

This does not happen if the stache directly use the model exported.

This is my code

---prestador.js ----
import can from 'can';
import superMap from 'can-connect/can/super-map/';
import tag from 'can-connect/can/tag/';
import 'can/map/define/define';
import moment from "moment";
import io from 'steal-socket.io';
export const Prestador = can.Map.extend({  define: {}  });
Prestador.List = can.List.extend({  Map: Prestador }, {});
export const prestadorConnection = superMap({
  url: '/api/v1/prestadores',
  idProp: 'CODIGOPRESTADOR',
  Map: Prestador,
  List: Prestador.List
});
const socket = io();
socket.on('prestadores-created',  prestador => {prestadorConnection.createInstance(prestador)});
socket.on('prestadores-updated',  prestador => {prestadorConnection.updateInstance(prestador)});
socket.on('prestadores-removed',  prestador => {prestadorConnection.destroyInstance(prestador)});
tag('prestador-model', prestadorConnection);
export default Prestador;

----- list.js  ----
...
import Prestador from 'app/models/prestador'
...
export var ViewModel = Map.extend({
  define: {
     ...
    prestadores: {
      get() {
        let params = {
          $limit: this.attr('paginate.limit'),
          $skip: this.attr('paginate.offset')
        };
        return Prestador.getList(params);
      }
    }
 ...
------list.stache -------------
   ...
{{#if prestadores.isPending}}
		Loading 
	{{/if}}
{{#if prestadores.isResolved}}
  {{#each prestadores.value}}
    <div class="list-group-item">
	      {{name}} - {{lastname}}
    </div>
  {{/each}}
{{/if}}

Any help is very useful.

What do you mean by:

LOSE modified record

It disappears? My guess is that your set logic isn’t right. You need to make sure that that modified record would pass algebra.has.

This means that if you loaded your data like:

Prestador.getList({foo: "bar"})

And your instance looks like {id: 1, something: "value"}.

You need to make sure

algebra.has({foo: "bar"}, {id: 1, something: "value"}) //-> true

Also, what do you mean by:

This does not happen if the stache directly use the model exported.

thanks for answer me.

Yes. when I work with two diferentes instances browser, the list that wasn’t modified, lost the data.
fortunately, now it is working.
My REST API is written with feathers-knex. For filter de data I use two params names $limit and $skip. This is the problem after update.
I don’t know why this happens.
My solution was write the algebra function for Prestador.

    export const prestadorConnection = superMap({
    ...
      Map: Prestador,
      List: Prestador.List,
      algebra:new set.Algebra({
      	"$sort" : function(){ return true },
      	"$limit" : function(){ return true },
      	"$skip" : function(){ return true },
      	"$select" : function(){ return true }
    })
    });

tag('prestador-model', prestadorConnection);

export default Prestador;

What I mean by :

This does not happen if the stache directly use the model exported.

This not happen when I use this way:

<prestador-model get-list="{}">
	{{#each ./value}}
		...
	{{/each}}
</prestador-model>

because there are unfiltered data.