/// <summary>
 /// Performs a manual compaction of this database, removing old irrelevant data
 /// and decreasing the size of the database file on disk
 /// </summary>
 public void Compact()
 {
     ThreadSafety.DoLockedBridge(err =>
     {
         CheckOpen();
         return(Native.c4db_compact(_c4db, err));
     });
 }
        public void DeleteIndex(string name)
        {
            CBDebug.MustNotBeNull(Log.To.Database, Tag, nameof(name), name);

            ThreadSafety.DoLockedBridge(err =>
            {
                CheckOpen();
                return(Native.c4db_deleteIndex(c4db, name, err));
            });
        }
        /// <summary>
        /// Sets the encryption key for the database.  If null, encryption is
        /// removed.
        /// </summary>
        /// <param name="key">The new key to encrypt the database with, or <c>null</c>
        /// to remove encryption</param>
        public void SetEncryptionKey([CanBeNull] EncryptionKey key)
        {
            ThreadSafety.DoLockedBridge(err =>
            {
                var newKey = new C4EncryptionKey
                {
                    algorithm = key == null ? C4EncryptionAlgorithm.None : C4EncryptionAlgorithm.AES256
                };

                if (key != null)
                {
                    var i = 0;
                    foreach (var b in key.KeyData)
                    {
                        newKey.bytes[i++] = b;
                    }
                }

                return(Native.c4db_rekey(c4db, &newKey, err));
            });
        }