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)
| 132 | /// |
| 133 | /// Returns `ViewAlreadyExists` if the view already exists. |
| 134 | pub fn create_shared_view(&mut self, name: &str) -> Result<(), RepositoryError> { |
| 135 | ensure_workspace_dir(&self.dot_dir, name)?; |
| 136 | |
| 137 | let mut txn = self |
| 138 | .pristine |
| 139 | .write_txn() |
| 140 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 141 | |
| 142 | if txn |
| 143 | .get_view(name) |
| 144 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 145 | .is_some() |
| 146 | { |
| 147 | return Err(RepositoryError::ViewAlreadyExists { |
| 148 | name: name.to_string(), |
| 149 | }); |
| 150 | } |
| 151 | |
| 152 | txn.create_view(name, ViewScope::Shared, None) |
| 153 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 154 | |
| 155 | txn.commit() |
| 156 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 157 | |
| 158 | Ok(()) |
| 159 | } |
| 160 | |
| 161 | /// Change a view's scope between Draft and Shared. |
| 162 | /// |
no test coverage detected