| Crates.io | moquilang |
| lib.rs | moquilang |
| version | 0.1.1 |
| created_at | 2025-10-05 07:46:29.48742+00 |
| updated_at | 2025-10-05 07:53:37.968529+00 |
| description | A WebAssembly module for entity operations and service calls with a database (default to a SQLite integration) |
| homepage | https://crates.io/crates/moquilang |
| repository | https://github.com/moquilabs |
| max_upload_size | |
| id | 1868742 |
| size | 1,320,019 |
This is a WebAssembly module built with Rust that provides entity operations and service calls for JavaScript applications. It includes a complete user management service and SQLite database integration.
pkg/ - Contains WebAssembly build artifacts and generated JavaScript bindings
static/ - Contains SQLite library and other JavaScript dependencies
index.html - Example HTML file demonstrating usage of the WebAssembly module
To use the WebAssembly module in your HTML file:
<!-- Include the SQLite library -->
<script src="./static/sqlite3.js"></script>
<!-- Import the WebAssembly module -->
<script type="module">
import init, { callService, createEntity, updateEntity, deleteEntity, findOne, findMany, exportDatabaseSchema } from './pkg/moquilang.js';
// Your code here
</script>
Calls a service with the given name and parameters. The parameters can be any JSON-serializable object. This function uses the JSON-based approach for serialization/deserialization between JavaScript and Rust, which can be more efficient in many cases.
import { callService } from "./pkg/moquilang.js";
// Example usage
const result = await callService("userService", {
userId: 123,
action: "getProfile",
options: {
includeDetails: true,
format: "full"
}
});
// The result will contain:
// {
// service: "userService",
// status: "success",
// parameters: "{userId: 123, action: \"getProfile\", options: {...}}"
// }
Note: This implementation uses the JSON-based approach with gloo-utils rather than direct JavaScript value manipulation with serde-wasm-bindgen. This approach:
The module provides the following entity operation functions:
Creates a new entity with the given name and data.
import { createEntity } from "./pkg/moquilang.js";
// Example usage
const result = await createEntity("UserAccount", {
username: "johndoe",
userFullName: "John Doe",
emailAddress: "john@example.com",
currentPassword: "password123",
disabled: "N"
});
Updates an existing entity. The entity ID must be included in the entityData.
import { updateEntity } from "./pkg/moquilang.js";
// Example usage
const result = await updateEntity("UserAccount", {
userId: "your-user-id-here",
userFullName: "John Smith",
emailAddress: "johnsmith@example.com"
});
Deletes an entity. The entity ID must be included in the entityData.
import { deleteEntity } from "./pkg/moquilang.js";
// Example usage
const result = await deleteEntity("UserAccount", {
userId: "your-user-id-here"
});
Finds one entity matching the query.
import { findOne } from "./pkg/moquilang.js";
// Example usage
const result = await findOne("UserAccount", {
userId: "your-user-id-here"
});
Finds multiple entities matching the query.
import { findMany } from "./pkg/moquilang.js";
// Example usage
const results = await findMany("UserAccount", {
"_limit": 10,
"_offset": 0,
"_orderBy": "username",
"_orderDir": "ASC"
});
# Build the Rust WebAssembly module
cargo build --target wasm32-unknown-unknown
The project includes a build.rs script that automatically runs wasm-bindgen after successful compilation when targeting wasm32-unknown-unknown. The generated files will be placed in the pkg/ directory.
For a release build:
cargo build --release --target wasm32-unknown-unknown
python -m http.server
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.