redis-om
This commit is contained in:
parent
5c6dfa1e0d
commit
4a9798c85e
|
|
@ -21,6 +21,7 @@
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"puppeteer": "^22.1.0",
|
"puppeteer": "^22.1.0",
|
||||||
"redis": "^4.6.13",
|
"redis": "^4.6.13",
|
||||||
|
"redis-om": "^0.4.3",
|
||||||
"winston": "^3.13.0",
|
"winston": "^3.13.0",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,42 @@
|
||||||
import {createLogger,transports, format} from 'winston';
|
import {createLogger,transports, format} from 'winston';
|
||||||
import { createClient } from 'redis';
|
import { createClient } from 'redis';
|
||||||
|
import { Repository, Schema, SchemaDefinition } from 'redis-om';
|
||||||
|
const baseListingSchemaDef : SchemaDefinition = {
|
||||||
|
id: { type: 'string' },
|
||||||
|
userId: { type: 'string' },
|
||||||
|
listingsCategory: { type: 'string' },
|
||||||
|
title: { type: 'string' },
|
||||||
|
description: { type: 'string' },
|
||||||
|
country: { type: 'string' },
|
||||||
|
state:{ type: 'string' },
|
||||||
|
city:{ type: 'string' },
|
||||||
|
zipCode: { type: 'number' },
|
||||||
|
type: { type: 'string' },
|
||||||
|
price: { type: 'number' },
|
||||||
|
favoritesForUser:{ type: 'string[]' },
|
||||||
|
hideImage:{ type: 'boolean' },
|
||||||
|
draft:{ type: 'boolean' },
|
||||||
|
created:{ type: 'date' },
|
||||||
|
updated:{ type: 'date' }
|
||||||
|
}
|
||||||
|
const businessListingSchemaDef : SchemaDefinition = {
|
||||||
|
...baseListingSchemaDef,
|
||||||
|
salesRevenue: { type: 'number' },
|
||||||
|
cashFlow: { type: 'number' },
|
||||||
|
employees: { type: 'number' },
|
||||||
|
established: { type: 'number' },
|
||||||
|
internalListingNumber: { type: 'number' },
|
||||||
|
realEstateIncluded:{ type: 'boolean' },
|
||||||
|
leasedLocation:{ type: 'boolean' },
|
||||||
|
franchiseResale:{ type: 'boolean' },
|
||||||
|
supportAndTraining: { type: 'string' },
|
||||||
|
reasonForSale: { type: 'string' },
|
||||||
|
brokerLicencing: { type: 'string' },
|
||||||
|
internals: { type: 'string' },
|
||||||
|
}
|
||||||
|
const businessListingSchema = new Schema('business',businessListingSchemaDef, {
|
||||||
|
dataStructure: 'JSON'
|
||||||
|
})
|
||||||
const logger = createLogger({
|
const logger = createLogger({
|
||||||
transports: [
|
transports: [
|
||||||
new transports.Console(),
|
new transports.Console(),
|
||||||
|
|
@ -15,11 +52,17 @@ const logger = createLogger({
|
||||||
const redis = await createClient()
|
const redis = await createClient()
|
||||||
.on('error', err => console.log('Redis Client Error', err))
|
.on('error', err => console.log('Redis Client Error', err))
|
||||||
.connect();
|
.connect();
|
||||||
|
const businessListingRepository = new Repository(businessListingSchema, redis);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
logger.info(`start findBusinessListings:`);
|
logger.info(`start findBusinessListings:`);
|
||||||
const result = await redis.ft.search('business:index','*',{LIMIT:{from:0,size:50}});
|
const result = await redis.ft.search('business:index','*',{LIMIT:{from:0,size:50}});
|
||||||
result.documents.forEach(d=>console.log(d));
|
//result.documents.forEach(d=>console.log(d));
|
||||||
logger.info(`end findBusinessListings:`);
|
logger.info(`end findBusinessListings:`);
|
||||||
|
|
||||||
|
logger.info(`start businessListingRepository:`);
|
||||||
|
await businessListingRepository.search().return.all()
|
||||||
|
logger.info(`end businessListingRepository:`);
|
||||||
|
|
||||||
redis.disconnect();
|
redis.disconnect();
|
||||||
})();
|
})();
|
||||||
Loading…
Reference in New Issue