Create a new Shared view with no parent. Changes inserted into a Shared view go into the global `GRAPH` table and are permanently visible to all views. This is the correct scope to use for server-side push targets, where changes must be universally visible regardless of which run or request inserts them. Returns `ViewAlreadyExists` if the view already exists.
(&mut self, name: &str)
| 137 | /// |
| 138 | /// Returns `ViewAlreadyExists` if the view already exists. |
| 139 | pub fn create_shared_view(&mut self, name: &str) -> Result<(), RepositoryError> { |
| 140 | ensure_workspace_dir(&self.dot_dir, name)?; |
| 141 | |
| 142 | let mut txn = self |
| 143 | .pristine |
| 144 | .write_txn() |
| 145 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 146 | |
| 147 | if txn |
| 148 | .get_view(name) |
| 149 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 150 | .is_some() |
| 151 | { |
| 152 | return Err(RepositoryError::ViewAlreadyExists { |
| 153 | name: name.to_string(), |
| 154 | }); |
| 155 | } |
| 156 | |
| 157 | txn.create_view(name, ViewScope::Shared, None) |
| 158 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 159 | |
| 160 | txn.commit() |
| 161 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 162 | |
| 163 | Ok(()) |
| 164 | } |
| 165 | |
| 166 | /// Change a view's scope between Draft and Shared. |
| 167 | /// |
no test coverage detected