@@ -76,15 +76,12 @@ Install the store plugin to get started.
7676<TabItem label = " JavaScript" >
7777
7878``` typescript
79- import { createStore } from ' @tauri-apps/plugin-store' ;
79+ import { load } from ' @tauri-apps/plugin-store' ;
8080// when using `"withGlobalTauri": true`, you may use
81- // const { createStore } = window.__TAURI__.store;
81+ // const { load } = window.__TAURI__.store;
8282
8383// create a new store or load the existing one
84- const store = await createStore (' store.bin' , {
85- // we can save automatically after each store modification
86- autoSave: true ,
87- });
84+ const store = await load (' store.bin' );
8885
8986// Set a value.
9087await store .set (' some-key' , { value: 5 });
@@ -111,7 +108,7 @@ pub fn run() {
111108 tauri :: Builder :: default ()
112109 . plugin (tauri_plugin_store :: Builder :: default (). build ())
113110 . setup (| app | {
114- let store = app . handle () . store_builder ( " store.bin " ) . build () ;
111+ let store = app . store ( " store.json " ) ? ;
115112
116113 // Note that values must be serde_json::Value instances,
117114 // otherwise, they will not be compatible with the JavaScript bindings.
@@ -121,11 +118,6 @@ pub fn run() {
121118 let value = store . get (" some-key" ). expect (" Failed to get value from store" );
122119 println! (" {}" , value ); // {"value":5}
123120
124- // You can manually save the store after making changes.
125- // Otherwise, it will save upon graceful exit as described above.
126- store . save ()? ;
127-
128-
129121 Ok (())
130122 })
131123 . run (tauri :: generate_context! ())
@@ -136,6 +128,32 @@ pub fn run() {
136128</TabItem >
137129</Tabs >
138130
131+ ## Migrating from v1 and v2 beta/rc
132+
133+
134+ <Tabs >
135+ <TabItem label = " JavaScript" >
136+
137+ ``` diff
138+ - import { Store } from '@tauri-apps/plugin-store';
139+ + import { LazyStore } from '@tauri-apps/plugin-store';
140+ ```
141+
142+ </TabItem >
143+ <TabItem label = " Rust" >
144+
145+ ``` diff
146+ - with_store(app.handle().clone(), stores, path, |store| {
147+ - store.insert("some-key".to_string(), json!({ "value": 5 }))?;
148+ - Ok(())
149+ - });
150+ + let store = app.store(path)?;
151+ + store.set("some-key".to_string(), json!({ "value": 5 }));
152+ ```
153+
154+ </TabItem >
155+ </Tabs >
156+
139157## Permissions
140158
141159By default all potentially dangerous plugin commands and scopes are blocked and cannot be accessed. You must modify the permissions in your ` capabilities ` configuration to enable these.
0 commit comments