Skip to content

Commit

Permalink
implement import function
Browse files Browse the repository at this point in the history
  • Loading branch information
macjuul committed Feb 7, 2025
1 parent 14868e5 commit fc37ef8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/surreal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ export function surrealdbWasmEngines(opts?: ConnectionOptions): Engines {
return this.db.export(options ? new Uint8Array(this.encodeCbor(options)) : undefined);
}

import(input: string): Promise<void> {
return this.db.import(input);
}

}

return {
Expand Down
8 changes: 7 additions & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use opt::endpoint::Options;
use serde_wasm_bindgen::from_value;
use surrealdb::dbs::Notification;
use surrealdb::dbs::Session;
use surrealdb::kvs::Datastore;
use surrealdb::kvs::export::Config;
use surrealdb::kvs::Datastore;
use surrealdb::rpc::format::cbor;
use surrealdb::rpc::method::Method;
use surrealdb::rpc::{Data, RpcContext};
Expand Down Expand Up @@ -123,6 +123,12 @@ impl SurrealWasmEngine {
Ok(result)
}

pub async fn import(&self, input: String) -> Result<(), Error> {
self.0.kvs.import(&input, &self.0.session).await?;

Ok(())
}

pub fn version() -> Result<String, Error> {
Ok(env!("SURREALDB_VERSION").into())
}
Expand Down

0 comments on commit fc37ef8

Please sign in to comment.