diff --git a/src/Couchbase.Lite.Shared/API/Database/Collection.cs b/src/Couchbase.Lite.Shared/API/Database/Collection.cs index 4e8aa6b68..6ebfecca3 100644 --- a/src/Couchbase.Lite.Shared/API/Database/Collection.cs +++ b/src/Couchbase.Lite.Shared/API/Database/Collection.cs @@ -953,6 +953,8 @@ private void Save(Document doc, C4Document** outDoc, C4Document* baseDoc, bool d #region Internal Methods + internal bool IsIndexTrained(string name) => LiteCoreBridge.Check(err => Native.c4coll_isIndexTrained(c4coll, name, err)); + /// /// Returns false if this collection has been deleted, or its database closed. /// diff --git a/src/LiteCore/binding_list/c4.def b/src/LiteCore/binding_list/c4.def index cf54fcd52..d3c971da7 100644 --- a/src/LiteCore/binding_list/c4.def +++ b/src/LiteCore/binding_list/c4.def @@ -37,6 +37,7 @@ c4coll_getDocExpiration c4coll_createIndex c4coll_deleteIndex c4coll_getIndexesInfo +c4coll_isIndexTrained c4db_copyNamed c4db_deleteNamed diff --git a/src/LiteCore/src/LiteCore.Shared/Interop/C4Index_native.cs b/src/LiteCore/src/LiteCore.Shared/Interop/C4Index_native.cs new file mode 100644 index 000000000..dfafd2688 --- /dev/null +++ b/src/LiteCore/src/LiteCore.Shared/Interop/C4Index_native.cs @@ -0,0 +1,48 @@ +// +// C4Index_native.cs +// +// Copyright (c) 2024 Couchbase, Inc All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Linq; +using System.Runtime.InteropServices; + +using LiteCore.Util; + +namespace LiteCore.Interop +{ + + internal unsafe static partial class Native + { + public static bool c4coll_isIndexTrained(C4Collection* collection, string? name, C4Error* outError) + { + using(var name_ = new C4String(name)) { + return NativeRaw.c4coll_isIndexTrained(collection, name_.AsFLSlice(), outError); + } + } + + + } + + internal unsafe static partial class NativeRaw + { + [DllImport(Constants.DllName, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool c4coll_isIndexTrained(C4Collection* collection, FLSlice name, C4Error* outError); + + + } +} diff --git a/src/LiteCore/src/LiteCore.Shared/LiteCore.Shared.projitems b/src/LiteCore/src/LiteCore.Shared/LiteCore.Shared.projitems index a1f3d38d2..079005709 100644 --- a/src/LiteCore/src/LiteCore.Shared/LiteCore.Shared.projitems +++ b/src/LiteCore/src/LiteCore.Shared/LiteCore.Shared.projitems @@ -33,6 +33,7 @@ +