geo coding, user service, listing for business

This commit is contained in:
2024-03-10 20:59:23 +01:00
parent 06f349d1c3
commit 6ad40b6dca
59 changed files with 120466 additions and 687 deletions

View File

@@ -0,0 +1,46 @@
import { Get, Inject, Injectable, Param } from '@nestjs/common';
import { createClient } from 'redis';
import { Entity, Repository, Schema } from 'redis-om';
import { User } from '../models/main.model.js';
import { REDIS_CLIENT } from '../redis/redis.module.js';
import { UserEntity } from '../models/server.model.js';
// export const redis = createClient({ url: 'redis://localhost:6379' })
@Injectable()
export class UserService {
userRepository:Repository;
userSchema = new Schema('user',{
// id: string;
firstname: { type: 'string' },
lastname: { type: 'string' },
email: { type: 'string' },
phoneNumber: { type: 'string' },
companyOverview:{ type: 'string' },
companyWebsite:{ type: 'string' },
companyLocation:{ type: 'string' },
offeredServices:{ type: 'string' },
areasServed:{ type: 'string' },
names:{ type: 'string[]', path:'$.licensedIn.name' },
values:{ type: 'string[]', path:'$.licensedIn.value' }
}, {
dataStructure: 'JSON'
})
constructor(@Inject(REDIS_CLIENT) private readonly client: any){
// const redis = createClient({ url: 'redis://localhost:6379' })
this.userRepository = new Repository(this.userSchema, client)
}
async getUserById( id:string){
return await this.userRepository.fetch(id);
}
async saveUser(user:any):Promise<UserEntity>{
return await this.userRepository.save(user.id,user) as UserEntity
}
// createUser(){
// }
// updateById(id:string){
// }
}