Add a placeholder for JavaScript fetch() function

This commit is contained in:
Tobie Morgan Hitchcock 2022-08-17 22:46:45 +01:00
parent d6de09bd0a
commit 890f2f527f
3 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,10 @@
use crate::sql::value::Value;
use js::Rest;
use js::Result;
#[js::bind(object, public)]
#[quickjs(rename = "fetch")]
#[allow(unused_variables)]
pub fn fetch(args: Rest<Value>) -> Result<Value> {
Ok(Value::None)
}

View file

@ -1 +1,2 @@
pub mod surrealdb; pub mod surrealdb;
pub mod fetch;

View file

@ -39,6 +39,8 @@ pub async fn run(
let global = ctx.globals(); let global = ctx.globals();
// Register the surrealdb module as a global object // Register the surrealdb module as a global object
global.init_def::<globals::surrealdb::Package>().unwrap(); global.init_def::<globals::surrealdb::Package>().unwrap();
// Register the fetch function as a global object
global.init_def::<globals::fetch::Fetch>()?;
// Register the Duration type as a global class // Register the Duration type as a global class
global.init_def::<classes::Duration>().unwrap(); global.init_def::<classes::Duration>().unwrap();
// Register the Record type as a global class // Register the Record type as a global class