The Next RealTime and Dynamic Server for Javascript / NodeJS

André Marques
3 min readDec 28, 2018

What if there was a javascript library that takes care of all the server side security, updating huge nested objects, iterating the data though objects, arrays, strings and getting everything you need really fast and really easily to implement?

I will introduce to you the main features we have been working on.

Getting Data

How it looks like in HTML

<div data-entangle=’this.innerHTML = this.retrieve(“user”, profile.username”);’></div>

Now the username is displayed and changes each time it’s updated in the server.

More Complex example

Url may be something like this:

www.myapp?user=f3jf9wmM3kwl3

We Get the user ID from URL:

var userID = Page.search.get(“user”);

We Synchronize the object with a named Entity (we called myAccount):

Data.getN(“myAccount”).sync(“user”, userID);

Now we can get what we need no matter if it’s a huge nested object

Example of Object:

//user data:{ username: “Andre”,
_profile_: "abcdefgh",
password: "******",
email: "*******",
_id: "zxymn"
}
//profile data:{
_id: "abcdefgh"
my_post_s: ["aaaa", "bbbb", "cccc"],
}
//first post data:{
creator: "zxymn",
text: "My Post Text",
likes: 57,
}

_type_ means it’s an ID to another Object

Getting the Data:

var result = myAccount.get("_profile_.my_post_s.~.text");

(~ means iterating though array or object)

Result:

["My Post Text", "My Another Text 2", "My 3 Text"];

Updating Data

It’s as simple as getting the data.

//adds a element to array1
myAccount.update("field1.field2.array1...", [newValue]);

Deleting Object fields + Arrays elements

For deleting, we just put * before the field:

//deleting field:
myAccount.update("field1.field2.*array1");
//deleting array element:
myAccount.update("field1.field2.array1.*", [element]);

Overflowing Data

To replace/overflow, we just use = before the field

myAccount.update("field1.field2.=array1", newArray);

How is Data protected?

We allow highly customized but still really simple way of filtering and protecting data. For example, if we want my post to be private to everyone but my friends:

rules = function(){  var friends = this.ad.get("creator(user)._profile_.friends");

if(!friends.contains(this.core.id))
this.filter("*");
};

Observe if certain parts change

We can create observers that bind to the data. Every time an array, string or object changes, our function is triggered.

myAccount.setBinder("_profile_.my_post_s", function(){   console.log("a post was added or removed");   this.data //posts array after modified
this.data_old //before modified
this.obj //new element
});

Triggering Functions in the server

All our functions are organized within folders. Some can only be executed by the server, others are public to be executed.

example of a function:

var private = false;var arguments = {arg1: 0, arg2: "", arg3: []};var func = function(args, cb){

//args.arg1...
};

They are protected by type. So if the user sends an argument as string instead of a number, it converts it to a string. Otherwise the server would crash if the users sends wrong data.

For triggering a server side function is easy.

srv.execute("folder1.folder2.name", {arg1: 65, arg2: "Hello"}, callBack);//we can have a callback from the servercallBack = function(args){
//the function was executed in the server
}

Join us on our small slack group and talk with us

https://join.slack.com/t/spreadbig/shared_invite/enQtNTEzNDI5NTk1NTczLWFhM2IwYmNmZTM4YmNjNTgxNTM0YTExYzNhYjRkNjU0YTkxYzdkNzhjMzdjYzEzODczNTViODdmYTcxOGFhMzA

--

--