You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: near-sdk/src/lib.rs
+32-2Lines changed: 32 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -147,8 +147,38 @@ extern crate quickcheck;
147
147
/// }
148
148
/// ```
149
149
///
150
-
/// It makes little sense to define
151
-
/// contract state without contract-specific methods to view and mutate its state.
150
+
/// ### Using SDK collections for storage
151
+
///
152
+
/// If contract state becomes large, collections from following modules can be used:
153
+
///
154
+
/// #### [`store`] module:
155
+
///
156
+
/// ```rust
157
+
/// # use near_sdk_macros::near;
158
+
/// use near_sdk::store::IterableMap;
159
+
///
160
+
/// #[near(contract_state)]
161
+
/// pub struct StatusMessage {
162
+
/// records: IterableMap<String, String>,
163
+
/// }
164
+
/// ```
165
+
///
166
+
/// * list of [**host functions**](store#calls-to-host-functions-used-in-implementation) used for [`store`] implementation
167
+
/// * **FAQ**: mutating state of collections from [`store`] module is only finally persisted on running [`Drop`/`flush`](store#faq-collections-of-this-module-only-persist-on-drop-and-flush)
168
+
///
169
+
/// #### [`collections`] module:
170
+
///
171
+
/// ```rust
172
+
/// # use near_sdk_macros::near;
173
+
/// use near_sdk::collections::LookupMap;
174
+
///
175
+
/// #[near(contract_state)]
176
+
/// pub struct StatusMessage {
177
+
/// records: LookupMap<String, String>,
178
+
/// }
179
+
/// ```
180
+
///
181
+
/// * list of [**host functions**](collections#calls-to-host-functions-used-in-implementation) used for [`collections`] implementation
0 commit comments