Opa

MongoDB: Perform a text-search in a document field (using high-level API)

好久不见. 提交于 2020-01-06 13:51:08
问题 It may be related to this question Basic GROUP BY statement using OPA MongoDB high level API. I want to be able to retrieve a list of documents which "name" field value contains a given string. Here's my documents list : {name: "Charles-Hugo"}, {name: "Jean Pierre"}, {name: "Pierre Dupont"}, I want to be able to only retrieve documents which name contains the "Pierre" string: Jean Pierre, and Pierre Dupont. I know this isn't possible with the MongoDB high-level API. I've looked in the low

Opa: Iterating through stringmap and forming a new string based on it

不羁的心 提交于 2020-01-04 05:35:17
问题 I'm editing the Hello-wiki code from Opa Documentation. I want a wiki-topic to have a list of the existing topics in the database. I have a function which is called on the default topic: /** * Collect all created topics from /wiki * and present them in Markdown format */ function collect_topics(page) { string collection = "#Available topics\n" // Format as a list Set.iter(function( topic ) { collection = "{collection} *[{topic}](./{topic})\n" }, [/wiki]) save_source(page, collection) } ...

How to do 'like' queries in Opa?

主宰稳场 提交于 2019-12-25 03:34:36
问题 My case is very simple. I need to do a contains/like search over a field. Based on this documentation you can do a regex to achieve this: items/item[name =~ ".*{value}.*"; skip pagination.startOn; limit pagination.numberOf; order +modifiedOn] But I'm getting a compilation error at the =~ operator. Checking the output of the compilation error I saw that this are the options that I've Hint: expected "!=" or "<" or "<=" or "==" or ">" or ">=" or "[" or "as" or "_" or "else" or "then" or "if" or

Basic GROUP BY statement using OPA MongoDB high level API

心不动则不痛 提交于 2019-12-14 03:02:19
问题 My question is quite simple: I'd like to perform a GROUP BY like statement with MongoDB using the OPAlang high level database API. But I don't think that is possible (?) If I do want to perform a mongodb $group operation, do I necessarily need to use the low-level API (using stdlib.apis.mongo ?) Finally, can I use both low-level and high-level APIs to communicate with my MongoDB ? Thanks. 回答1: I am afraid that, taking into account latest published Opa compiler code, no aggregation is

parsing a webclient.Result content in OPA

核能气质少年 提交于 2019-12-13 12:37:01
问题 I am trying to use the webclient module to query the couchDB rest interface (I am using it instead of the opa couchdb api because I need to get a specific number of documents). Here is the code used to make the query: listmydocs(dburi)= match WebClient.Get.try_get(dburi) with | { failure = _ } -> print("error\n") | {success=s} -> match WebClient.Result.get_class(s) with | {success} -> print("{s.content}") | _ -> print("Error {s.code}") end the result given in s.content is the following string

Opa chat app not working

拈花ヽ惹草 提交于 2019-12-13 01:53:58
问题 I copied opa chat application. It's working on OSX Lion but not on my 32 bit linux machine. I know that 32 bit is not supported but I was able to compile opa. I then compiled chat app. When I access it, I get the initial page but when I add some text to chat, that text is not displayed. I don't know how to debug this. I have increased the verbosity to 8. What else can I do to debug this? Thanks Prabhat Gupta 回答1: As pointed out by Hugo, 32 bits is not officially supported. However, from your

opa : sending mail

最后都变了- 提交于 2019-12-13 01:27:05
问题 I'm trying to send an email using SmtpClient.try_send(). This code used to work before opa switch to the node.js backend : import stdlib.web.mail.smtp.client import stdlib.web.mail function start() { Email.email from = {name:some("name"), address:{local:"contact", domain:"hello.com"}} Email.email to = {name:some("name"), address:{local:"contact", domain:"hello.com"}} Email.content content = {text : "This is Great!"} SmtpClient.try_send(from, to, "subject",content, Email.default_options) <

Looping over db intmap(person)

徘徊边缘 提交于 2019-12-12 19:41:45
问题 example: type person = { name : string ; age : int } db /person : intmap(person) I know how to get a single person from the db, but how do I get them all? and print them in a html table? Thx. 回答1: I advise you to use Db.intmap_fold_range instead of InMap.fold. It will be faster than InMap.fold which need to build the all map in OPA before folding on it. http://opalang.org/resources/doc/index.html#db.opa.html/!/value_stdlib.core.db.Db.intmap_fold_range Here is an example for your type: type

Opa won't compile hello_web.opa

ぐ巨炮叔叔 提交于 2019-12-11 04:45:55
问题 I'm following the http://blog.opalang.org/2011/06/first-steps-hello-web-in-opa.html, so the code is simply: server = Server.one_page_server("Hello", ( -> <>Hello web</>)) saved to hello.opa, then I try to compile: me@myhost:~/src/opa/helloweb$ opa hello.opa sh: as: not found File "bsl_init_.ml", line 1, characters 0-1: Error: Assembler error, input left in file /tmp/camlasm313d73.s make: *** [bsl_init_.cmx] Error 2 error during ocaml compilation -- the command was : make --makefile

Error during the build from source

只愿长相守 提交于 2019-12-07 12:30:19
问题 I have a 32bit architecture so I must build opa from source. Configure works fine: ./configure -ocamlopt /opt/opa/bin/ocamlopt.opt -ocamlfind /opt/opa/bin/ocamlfind Checking your OS... Linux Checking your architecture... ix86 Checking ocamlopt... /opt/opa/bin/ocamlopt.opt Checking ocamlbuild... /opt/opa/bin/ocamlbuild Checking ocamldir... /opt/opa/lib/ocaml Checking ocaml version... 3.12.0 Checking your ocaml setup... 3.12.0, Unix 32bit Checking for camlp4... /opt/opa/bin/camlp4o Checking for