These are chat archives for canjs/canjs

25th
Sep 2017
Nico R.
@nriesco
Sep 25 2017 01:36
Is it possible to limit the number of results to 1 when using getList? It can be either there or somehow in the stache. I now use the "each" tag
Nico R.
@nriesco
Sep 25 2017 01:52
something like:
getList(condition, {limit: 1})
or
getList(condition).limit(1)
Nico R.
@nriesco
Sep 25 2017 02:06
or maybe getList({$limit: 1}) ? is that valid?
Frank Lemanschik
@frank-dspeed
Sep 25 2017 07:35
good point my frind now it gets complex :)
getList normal gets set from the connection if it uses canMap Behavier
so it depends on your connection and server if that works its right in your code example
you need to add limit as condition
or else you do getList like you do it now and just do list.pop() === only 1 result from the list that by the way in the moment when u use pop is not anymore in the list :)
but if you only want a single item maybe .get('id')
would be more what your searching for
Nico R.
@nriesco
Sep 25 2017 11:21
But I need to search , not by I’d by other attribute
Because I don’t know the Id
Frank Lemanschik
@frank-dspeed
Sep 25 2017 12:25
then you do filter
if you want to search
https://github.com/pixelsandbytes/caller-id is that maybe a good can-debug for the maps?
@nriesco
bla.getList().then((list) => list.filter((itm)=>itm.id === id))
after that .then() you got with luck only one item that has the id that you setted as id
you can filter for anything
filter returns only the items that are true to the if condition
read about that google Array.filter javascript
DefineLists are Arrays
but best would be to solve that in the backend :)
Frank Lemanschik
@frank-dspeed
Sep 25 2017 12:30
and do getList(conditions) and that returns only 1
or you make a extra api endpoint only for that condition
Nico R.
@nriesco
Sep 25 2017 14:08
thanks @frank-dspeed I think that won’t work for me, because it will still get all the results. Get is not an options because I do not have the Id yet, anyway, I’ll find a workaround
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 18:44
DefineLists aren't really Arrays, but do implement all of the ES5 Array functions.
We'll also add in ES2015+ functions if enough people request it
Frank Lemanschik
@frank-dspeed
Sep 25 2017 19:22
@nriesco code a simple api endpoint for that where is the problem?
there is something that you know a criteria probally
make /api/criteriaName/crit
and let it return only that one result get it via get(crit)
@bmomberger-bitovi sure your right i am answering most time a bit none technical because thats more easy to understand sure i can say ok listen
this is a JavaScript Proxy :)
and so on
but that would be most time to much explaining the framework should take care of that if he handels definelists as array he will get probally the results that he expects
thats why i sayed they are arrays but thanks for pointing that out
i regonize that also often with justin heheeh he always is exact at every word not flexible :)
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:04
I don't want people to get the wrong idea and think that if they're writing for a browser that supports extra features on Arrays, that they can be used in DefineLists. It's a subtle case but will cause you hours of grief if you don't know
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:12
possible sure
many things can be abused i did it all :)
but it leads to a good learning curve
i am now on top of all JavaScript features only to understand what i did wrong with canjs
I know now Relections Proxys Symbols
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:18
@bmomberger-bitovi what do you think about https://www.npmjs.com/package/caller-id it looks like its a natural fit for defineMap
:D
and list
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:26
It's computationally expensive to trap and throw errors, which is generally how you get that kind of data. We would have to have a library that injects instrumentation into the code in dev mode.
And that's still not the biggest problem with trying to trace VM and model changes -- still a bigger headache that updates are batched and you lose the stack waiting for it to flush.
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:27
ya we can use JavaScript Proxys
but keeping a batch history is small
there are not 100k tasks per minut that need to get traced
i think implamenting this only on throw alone would be a good idea
without additional code changes i will test it out and if it works simply JavaScript Proxy implament that
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:29
Cool.
If it works you should join the DoneJS Contributors meeting on Friday and demo it.
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:30
i will not have that ready till friday i am at present working on much contributions i think the first that i will demo is something like the new single binary
can donejs-canjs
a generator that pins canjs versions based on the canjs/canjs repo
stuff like that
i have a lot to demo need to do a roadmap will need 2 more weeks to even clean that all up
i am also investigating in open source my new http/http2/ws server written in C
and bundle it with steal-server and write a production deployment guide
then i need to get the lib from the opensource server directly nodejs binded so you see a lot of work all over the place :)
but its worth the effort as it now in private deployments outperforms nginx by far and also adds extra nice features like cache aware http2 push and so on
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:34
Wow
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:34
will integrate that then into donejs webworker implamentation and so on
a big big roadmap
and i am a 1 guy team
i only do it for the passion :)
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:35
Right. That's impressive and also concerning.
Has anyone done a security audit on it yet?
When I hear "I just wrote a fast HTTP server in C" what I interpret is "I just caused Heartbleed all over again"
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:36
a more then 100% faster one then nginx
with less cpu ram usage :)
and soon nativ nodejs scripting support
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:38
I'm serious, though, you need to have someone find all the ways to break it.
Insecure Web server software is a Very Bad Thing™
I would rather lose 50% performance to use a hardened nginx rather than risk my clients' data
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:40
hehehe i am working with specialists :)
its secure and supports newst ssl cyphers
its really hardned thats why its fast
it has no stuff thats not needed
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:41
Cool. That's reassuring.
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:41
it has at present mruby scripting and lua support that you can compile
if you need it
but i also export at present a lib
and i want to use that nativ with nodejs
to add nodejs scripting at present its even hell fast to only proxy to nodejs
it even mastered the magic 1 mio connections example
at the same time
:)
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:43
I look forward to the Medium article "Breaking the 1 Million connections barrier in Node.js"
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:43
i did it often
i saw it one time from a russian copyed it and it worked since then i was addicted to nodejs and droped php and all that
replaced even bash code with node :)
my current view is all should be js code only the high performance frontend facing parts need to be C
i even love emscripten you probally know it
i play often with it converting windows software to javascript
wanted to open my own game application streaming provider
but never found the energie to apply for funding and that
some examples like doom and unreal engine converted and running nativ in the browser
:D
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:46
Yeah I've seen the videos
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:47
its amazing soon we will be able to run every thing in the browsers
via streaming i like that concept because it enables totally new distributed computing power
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:48
I liked browsers better when they were called operating systems.
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:48
together with the concepts of p2p and blockchain and even p2p-blockchain
you can run complet games as a distributed blockchain
:D
Brad Momberger
@bmomberger-bitovi
Sep 25 2017 20:49
Blockchain isn't meant to be real time. There's no way you'll be able to do 30 transaction blocks per second.
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:49
this smart contracts and blockchain stuff opens infinity computing
sure i can do 30 blocks per secund
with a central state
no problem
but it will still do a lot of stuff via p2p i also use that when i scale services
i don't scale for example feathers
i let feathers use a distributed job queue where it adds jobs on requests
then other boxes fullfill the job and feathers responses
so i simply scale the job workers
and can make sure the jobs are distrubted executed once and so on
realtime ;)
Frank Lemanschik
@frank-dspeed
Sep 25 2017 20:59
and about the blockchain your talking about long chains meand more a complet own chain per player or game