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