diff --git a/README.md b/README.md index 8809256..156e5cd 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ cargo build --release --target x86_64-unknown-linux-gnu # Building wasm32 binary cargo build --release --target wasm32-unknown-unknown # Building using wasm-pack -bunx wasm-pack build --release --target web +bunx wasm-pack build --release ``` ## Running diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index ace60a2..4acb104 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -710,6 +710,28 @@ impl Client { } } + #[wasm_bindgen(js_name = getAllEntities)] + pub async fn get_all_entities(&self, limit: u32, offset: u32) -> Result { + #[cfg(feature = "console-error-panic")] + console_error_panic_hook::set_once(); + + let results = self + .inner + .entities(torii_grpc::types::Query { + limit, + offset, + clause: None, + }) + .await; + + match results { + Ok(entities) => Ok(js_sys::JSON::parse( + &parse_entities_as_json_str(entities).to_string(), + )?), + Err(err) => Err(JsValue::from(format!("failed to get entities: {err}"))), + } + } + #[wasm_bindgen(js_name = getEventMessages)] pub async fn get_event_messages(&self, query: Query) -> Result { #[cfg(feature = "console-error-panic")]