123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /* the key is to do it in one line. Client just pass 2 arguments, one is the location of the data, which could be file, sql or mongodb, and also
- pass in the conditions of their search enquiries. We will aslo have to cater to different file storage location to determine how to prep the
- data to be filtered
- */
- import { Observable } from "rxjs"
- import { queryService } from "../services/query.service"
- import { Conditions, Storage } from "../services/query.service"
- import { _, isObject } from 'lodash'
- let query = new queryService()
- //For now just local file storage. More will be preapred in the design phase later.
- let storageAddress: Storage = {
- type: "File",
- address: "payload.json"
- }
- // Array inquiry: should return mutiple data
- let conditions1: Conditions[] = [
- { 'msgTag': ['free'] }
- ]
- // Basic inquiry, but with multi search: should return one data
- let conditions2: Conditions[] = [
- { "msgId": "4f710c4b-a258-4c7e-a4b6-6095bb7028e9" },
- { "msgLogDateTime": "2023-01-14T21:50:19.917Z" },
- ]
- // Value only argument! : should return one data
- let conditions3: Conditions[] = [
- { "regex": "cum incidunt maxime voluptatibus" }
- ]
- // Date Range inquiry: Should return multiple data
- let conditions4: Conditions[] = [
- {
- "dateRange": {
- "startDate": "2023-04-09T21:00:00.000Z",
- 'endDate': "2023-04-10T00:00:00.000Z"
- }
- }
- ]
- // Multi conditions except for regex search: Should return at least 1 data
- let conditions5: Conditions[] = [
- {
- "dateRange": {
- "startDate": "2023-04-09T21:00:00.000Z",
- 'endDate': "2023-04-10T00:00:00.000Z"
- }
- },
- { 'msgTag': ['basic'] },
- { "msgId": "4f710c4b-a258-4c7e-a4b6-6095bb7028e9" },
- { "msgLogDateTime": "2023-01-14T21:50:19.917Z" }
- ]
- // Ultimate search. With all conditions piling at once: Should at least returns 1 data
- let conditions6: Conditions[] = [
- {
- "dateRange": {
- "startDate": "2023-04-09T21:00:00.000Z",
- 'endDate': "2023-04-10T00:00:00.000Z"
- }
- },
- { "regex": "maxime voluptatibus ad quasi eveniet" },
- { 'msgTag': ['basic'] },
- { "msgId": "4f710c4b-a258-4c7e-a4b6-6095bb7028e9" },
- { "msgLogDateTime": "2023-01-14T21:50:19.917Z" }
- ]
- query.query(storageAddress, ...conditions6).subscribe((element) => { console.log(`${element.header.messageName} is matched`) })
|