dce-mango
Version:
Harvard DCE's Non-relational DB Wrapper.
30 lines (27 loc) • 1.12 kB
text/typescript
// 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<DocumentType> {
/**
* 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<Result>(
opts: {
idOrIdsToLock: Id | Id[],
procedure: CollectionProcedure<DocumentType, Result>,
},
): Promise<Result>;
}
export default CoconutInterface;