mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: remove path alias.
feat: remove Webpack and depend on nodemon. feat: refactoring expenses. feat: optimize system users with caching. feat: architecture tenant optimize.
This commit is contained in:
21
server/src/system/repositories/SubscriptionRepository.ts
Normal file
21
server/src/system/repositories/SubscriptionRepository.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import SystemRepository from "system/repositories/SystemRepository";
|
||||
import { PlanSubscription } from 'system/models'
|
||||
|
||||
@Service()
|
||||
export default class SubscriptionRepository extends SystemRepository{
|
||||
@Inject('cache')
|
||||
cache: any;
|
||||
|
||||
/**
|
||||
* Retrieve subscription from a given slug in specific tenant.
|
||||
* @param {string} slug
|
||||
* @param {number] tenantId
|
||||
*/
|
||||
getBySlugInTenant(slug: string, tenantId: number) {
|
||||
const key = `subscription.slug.${slug}.tenant.${tenantId}`;
|
||||
return this.cache.get(key, () => {
|
||||
return PlanSubscription.query().findOne('slug', slug).where('tenant_id', tenantId);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user