Using math.js in Functions

瀏覽次數:52 次
跳到第一則未讀訊息

Tore

未讀,
2016年7月11日 下午3:09:302016/7/11
收件者:OrientDB
Trying to utilize math....() in a function (javascript).
If this can be done, is there a way to use a function in a query? 
e.g. select math.asinh(XXX) as yyy from ...

Luca Garulli

未讀,
2016年7月11日 晚上10:03:092016/7/11
收件者:OrientDB
You can use the Java math for sure: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html

Example:

var value = java.lang.Math.abs( v );



Best Regards,

Luca Garulli
Founder & CEO


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tore

未讀,
2016年7月12日 清晨7:24:552016/7/12
收件者:OrientDB
Thanks Luca.
Still, the question is really about using a function written in Studio/Functions. Lets assume I write a javascript
function in Studio called snug(p), with one parameter. Can I use this in a select statement, e.g. select snug(Sfactor) from Foo...
Saw some discussion about that somewhere. Can this be done?

Luca Garulli

未讀,
2016年7月12日 上午9:03:092016/7/12
收件者:OrientDB
Hi Tore,

Sure you can call any function from SQL.

Best Regards,

Luca Garulli
Founder & CEO


Tore

未讀,
2016年7月12日 下午1:50:262016/7/12
收件者:OrientDB
Indeed. I misread another thread. May be an explicit example should be included in the docs?
Thanks again.

Luca Garulli

未讀,
2016年7月12日 下午2:05:512016/7/12
收件者:OrientDB
You're right, just added this example:


It will go to the official documentation in the next hours.

Best Regards,

Luca Garulli
Founder & CEO


Tore Austrått

未讀,
2016年7月12日 下午3:09:452016/7/12
收件者:orient-...@googlegroups.com
Excellent Luca.
How do I use math.js (which I installed) in Javascript functions?
It obviously works in node. What does it take to reference it in a "Functions-function"?
 

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/38Oema7nruU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Tore Austrått
phone +47 90657231

Tore

未讀,
2016年7月19日 上午9:06:082016/7/19
收件者:OrientDB
It worked just fine after correcting a mistyping and adding, actually guessing, the phrase: parseFloat(arg). Can someone please
add a few words about this parse-stuff in Functions -  in the doc?


// The Math.log() function returns the natural logarithm (base e) of a number.
return Math.log(parseFloat(arg) + Math.sqrt(parseFloat(arg) * parseFloat(arg) + 1));

select arcsinh(foo) from bigFoo group by, etc delivers what's expected.

Cheers,
Tore
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/38Oema7nruU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-database+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
回覆所有人
回覆作者
轉寄
0 則新訊息