mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
refactor: manual journal.
This commit is contained in:
37
server/src/repositories/ContactRepository.ts
Normal file
37
server/src/repositories/ContactRepository.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import TenantRepository from 'repositories/TenantRepository';
|
||||
|
||||
export default class ContactRepository extends TenantRepository {
|
||||
cache: any;
|
||||
models: any;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {number} tenantId - The given tenant id.
|
||||
*/
|
||||
constructor(
|
||||
tenantId: number,
|
||||
) {
|
||||
super(tenantId);
|
||||
|
||||
this.models = this.tenancy.models(tenantId);
|
||||
this.cache = this.tenancy.cache(tenantId);
|
||||
}
|
||||
|
||||
findById(contactId: number) {
|
||||
const { Contact } = this.models;
|
||||
return this.cache.get(`contact.id.${contactId}`, () => {
|
||||
return Contact.query().findById(contactId);
|
||||
})
|
||||
}
|
||||
|
||||
findByIds(contactIds: number[]) {
|
||||
const { Contact } = this.models;
|
||||
return this.cache.get(`contact.ids.${contactIds.join(',')}`, () => {
|
||||
return Contact.query().whereIn('id', contactIds);
|
||||
});
|
||||
}
|
||||
|
||||
insert(contact) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user