| 95 | } |
| 96 | |
| 97 | func (db *Database) PutDesignDoc(ctx context.Context, ddocName string, ddoc sgbucket.DesignDoc) (err error) { |
| 98 | wrap := true |
| 99 | if opts := ddoc.Options; opts != nil { |
| 100 | if opts.Raw == true { |
| 101 | wrap = false |
| 102 | } |
| 103 | } |
| 104 | if wrap { |
| 105 | wrapViews(&ddoc, db.GetUserViewsEnabled(), db.UseXattrs()) |
| 106 | } |
| 107 | |
| 108 | vs, err := getViewStoreForDefaultCollection(db.DatabaseContext) |
| 109 | if err != nil { |
| 110 | return err |
| 111 | } |
| 112 | if err = db.checkDDocAccess(ddocName); err == nil { |
| 113 | err = vs.PutDDoc(ctx, ddocName, &ddoc) |
| 114 | } |
| 115 | return |
| 116 | } |
| 117 | |
| 118 | const ( |
| 119 | // viewWrapper_adminViews adds the rev to metadata, and strips the _sync property from the view result |