Skip to content

How to use the indexed_db via web-sys #1476

Closed
@bigfish3000

Description

@bigfish3000

How to use the indexed via web-sys, do some one have examples ?

Who can show me the examples?

I can not access the indexed_db like this:

        let db = window!().indexed_db().unwrap().unwrap();
        let opened_request = match db.open("test-my") { 
            Ok(v) => { v },
            Err(res) => { 
                let s = Array::from(&res);
                console::log(&s);
                return;
            }
        };
        let trans = match opened_request.transaction() {  
            Some(v) => { v },
            None => { 
                log_info_str!("Can not get transaction"); //It always show me error!
                return;
            }
        };
        let db = trans.db();
        let store = match db.create_object_store("my-test") { 
            Ok(v) => { v },
            Err(err) => {                 
                let s = Array::from(&err);
                console::log(&s);
                return;
            }
        };
        let js = JsValue::from("hello world");
        let _request = match store.put(&js)  { 
            Ok(v) => { v },
            Err(err) => {                 
                let s = Array::from(&err);
                console::log(&s);
                return;
            }
        };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions