// Import types import CollectionProcedure from './CollectionProcedure'; import Id from '../types/Id'; /** * Interface for mutable, concurrent update patterns. * Pass in a closure which executes any number of methods on the collection. * @author Benedikt Arnarsson */ interface CoconutInterface { /** * Given a function representing a set of operations on the collection and a set of ids to lock, * will run the function such that other collections cannot make modifications while the function runs. * For use in situations with multiple concurrent servers using the same database. * @author Benedikt Arnarsson * @param opts object containing all parameters * @param opts.idOrIdsToLock the one Id or list of Ids to lock for the procedure provided. * @param opts.procedure the procedure that is being wrapped in the lock-unlock calls * @returns the result of opts.procedure */ runAtomicProcedure( opts: { idOrIdsToLock: Id | Id[], procedure: CollectionProcedure, }, ): Promise; } export default CoconutInterface;