Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] NodeJS support #708

Open
silvioprog opened this issue May 13, 2019 · 8 comments
Open

[question] NodeJS support #708

silvioprog opened this issue May 13, 2019 · 8 comments
Labels
enhancement New feature or request help wanted Looking for insight or contributors

Comments

@silvioprog
Copy link

silvioprog commented May 13, 2019

Hello.

Is there any plan to support NodeJS?

Thank you!

@greenrobot
Copy link
Member

While it's something we'd like to do, our small team is currently focused on different tasks.

Community volunteers could do this using ObjectBox C API; we'd definitely be supportive.

@greenrobot greenrobot added enhancement New feature or request help wanted Looking for insight or contributors labels May 13, 2019
@silvioprog
Copy link
Author

Thanks a lot for answering! (should I keep this issue open to notify volunteers?)

@greenrobot
Copy link
Member

greenrobot commented May 16, 2019

Yes, let's leave that open at least for reference and tracking user interest (give a 👍 at the top).

@Buggaboo
Copy link

Here's a crazy idea: transpile the ObjectBox C API, using Emscripten? And then store the data.mdb in window.localStorage?

@Buggaboo
Copy link

Buggaboo commented Jun 27, 2019

Update: so I was tinkering with transpiling objectbox-c to wasm/js:

Prepare the toolset:

#!/bin/bash
git clone https://github.com/emscripten-core/emsdk.git ; cd emsdk ; ./emsdk install latest ; ./emsdk activate latest ; source ./emsdk_env.sh
cd .. ; git clone https://github.com/objectbox/objectbox-c.git ; cd objectbox-c ; chmod +x download.sh ; ./download.sh

Then you can experiment with the following:

emcc -Werror -Llib -lobjectbox -Iinclude -Iexternal -o objectbox-js-test.html src-test/plain-c-test-main.c

Update:
It seems that the drop-in objectbox core library (not ready yet for the public? #461 ) in the objectbox-c api has mangled names, so undefined symbols will prevent generating wast from it. Maybe the mac dylib version specifically has issues, dunno.

My conclusion: until the source code for the core is made available, transpiling to wasm for nodeJS support seems unlikely to happen. Wrapping the objectbox-c API for your target language X seems to be the way to provide support for objectbox.

Although, I was able to transpile the monster sample for flatcc to wasm.

# set up emscripten if necessary
cd .. ; git clone https://github.com/dvidelabs/flatcc ; cd flatcc
# compile c and generate from fbs
cmake . ; make
# transpile samples/monster
emcc -Werror -Iinclude -Isamples/monster/generated -o flatcc-js-monster.html src/runtime/*.c samples/monster/monster.c

Your express script to setup the correct mime type to run from a browser:

var express = require('express');
var app = express();
 
express.static.mime.types['wasm'] = 'application/wasm'; 
app.use(express.static(__dirname + '/'));

Direct your browser to http://localhost:8080/flatcc-js-monster.html

Theoretically, provided that we have the correct offsets, schema, versioning etc. required to read from the buffer (based on a objectbox database), you could read an objectbox database from the browser/nodejs, using a transpiled a flatcc program.

@lanmower
Copy link

lanmower commented Jul 2, 2021

There are thousands of native libraries for node, how hard can it be? Why transpile?

@swise0
Copy link

swise0 commented Mar 24, 2022

Interested in using this database on the web platform..

@Buggaboo
Copy link

Transpile for the necessary plumbing to put / get data from storage, based on your schema. IIRC, there's some work done on objectbox-dart support for the web. Maybe you could call the generated objectbox related javascript from objectbox-dart, on node, without flutter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Looking for insight or contributors
Projects
None yet
Development

No branches or pull requests

5 participants