Setting collection persistance via js

Hi

I´m building sort of a shop using Noodl. In it i have two different devices, one showing the shopping interface and the other showing the backend with placed orders and so on.

When an order is created an Order item, a model, is created containing info about the order and also a Collection containing all the order items, which are models with their own parameters.

The collection containing order items, and the order items, is created in a js node which sets unique ids to both order items and the collection containing them. The collection is then added to the order which is then added to the order list.

Then at the backend I´m listing all the orders and you can click on them to show their info and their order items from the collection.

So my problem. When I´m running everything locally through Noodl on my computer the orders show up just fine on the backend I can click on them and show the order items of a order. But when showing the shopping interface and placing an order from a separate device the collection containing the order items get lost, or doesn´t get transferred to the other device. I know this because I run Noodl.Collection.exists(“xxx”) in the console in both cases.

I also get this error message when trying to display the information about an order in the backend, when it doesn´t work.

image

Maybe also worth mentioning is that if I start by adding some orders while running all interfaces on the same device they work, but as soon as an order is added from another device all orders stop working even though I can see that the locally created order item collections still exist.

I guess that this must be a persistance issue and that when I create the collection with order items and the models for the order items they get none or local persistence and hence aren´t available to the other device when running several devices.

So my question is how do I solve this, can I set persistance to global via js or is there some other solution I can use to solve this problem?

Hoping someone out there can help me because this is driving me crazy.

Best regards,
Göran

Hi Göran,

Not an expert by far, but it would be helpful to see some code/images/videos of the problem you’re describing. I’d love to help out.

I’ve manipulated a collection (with ‘SYNC’ persistence) in a JS node like this before. This was in ‘window event listener’ with sending a signal (event sender) to ‘remove’ an item from collection for other viewers of prototype.

var col = Noodl.Collection.get(“client”);

console.log(“Looking for collection: " + col);
console.log(“Does it exist?: " + Noodl.Collection.exists(“col”));
console.log(“Check for itemNumber: " + inputs.itemNR);
console.log(“ItemNumber exists?: " + col.contains(Noodl.Model.get(inputs.itemNR)));
col.remove(Noodl.Model.get(inputs.itemNR));
console.log(“Does item exist in collection after deletion?: " + col.contains(Noodl.Model.get(inputs.itemNR)));

self.sendSignalOnOutput("ping");

Regi

I’d love to help, is it possible for you to create a small simple project showing the issue and post it?

Hi,

Thanks for the replies. I´ll see if I can setup a small example project that I can post.

//Göran