couchdb_orm/structs/mod.rs
1// Copyright (C) 2020-2023 OpenToolAdd
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15// contact: contact@tool-add.com
16
17use std::collections::HashMap;
18use uuid::Uuid;
19
20#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
21pub struct DesignDoc {
22 #[serde(rename = "_id")]
23 pub id: Option<String>,
24 #[serde(rename = "_rev", skip_serializing_if = "Option::is_none")]
25 pub rev: Option<String>,
26 pub views: HashMap<String, HashMap<String, String>>,
27}
28
29impl DesignDoc {
30 pub fn new(views: HashMap<String, HashMap<String, String>>) -> DesignDoc {
31 DesignDoc {
32 id: Some(Uuid::new_v4().to_string()),
33 rev: None,
34 views,
35 }
36 }
37}