I want to store data in the following style in Redis database:
{ _id: 5b3a60cdccbdf81bcc5343e6,
id: 5b3a60cdccbdf81bcc5343e5,
position: 'Web dveloper',
type: 'Contract',
Skills: 'html, bootstrap,php',
location: 'Boston',
job_id: 1,
Experience: '0-6 months',
Description: 'Developer for websites and web apps',
__v: 0 },
{ _id: 5b3a6151ccbdf81bcc5343e8,
id: 5b3a6151ccbdf81bcc5343e7,
position: 'Data analyst',
type: 'contract',
Skills: 'big data, hadoop,python',
location: 'boston',
job_id: 2,
Experience: '1yr',
Description: 'for analysing incoming data',
__v: 0 },
{ _id: 5b3a6207ccbdf81bcc5343ea,
id: 5b3a6207ccbdf81bcc5343e9,
position: 'Content Writer',
type: 'Permanent',
Skills: 'Technical wirtting,Custmer engagement',
location: 'new jersey',
job_id: 3,
Experience: '0-6 months',
Description: 'for writting website content',
__v: 0 },
{ _id: 5b3a62c4ccbdf81bcc5343ec,
id: 5b3a62c4ccbdf81bcc5343eb,
position: 'node js specialist',
type: 'Permanent',
Skills: 'node js ,express js , mean stack',
location: 'boston',
job_id: 4,
Experience: '1yr',
Description: 'for the web apps',
__v: 0 },
{ _id: 5b3a6362ccbdf81bcc5343ee,
id: 5b3a6362ccbdf81bcc5343ed,
position: 'database expert',
type: 'temporary',
Skills: 'sql , no sql, mysql,sql server,mongo db',
location: 'boston',
job_id: 5,
Experience: '2 yrs',
Description: 'for desinging and maintaing databases',
__v: 0 },
{ _id: 5b3a8639c8323b2cfc179969,
id: 5b3a8639c8323b2cfc179968,
position: 'Social media manager',
type: 'Permanent',
Skills: 'Social media marketing,Digital marketing',
location: 'Boston',
job_id: 4,
Experience: '1yr',
Description: 'For managing company socail media accounts',
__v: 0 }
I have gone through Redis official documentation but I have found nothing. Can anybody guide what structure I can use to store and how I can retrieve these data in table?
One of the alternatives you could use to store your data is the Redis Hash data structure. Using the Redis Hash structure, you could store your entities using the id as the key, then map the remaining fields into a Redis Hash using the HMSET command.
The recommended client for Node.js is the npm Redis package. This will provide all of the functionality you need to interact with Redis.
Ultimately, your query patterns are going to determine the optimal structure for your data. Using a hash is a very basic entity mapping approach to the problem, but it might not be the best way to structure the data. There may be more efficient ways to structure the data depending on how you plan to use it.
Redis doesn't offer that much structure directly, but there are layered libraries that do. I am trying to use Walrus, a Python library, that offers that capability atop Redis.
Related
When getting the order information form the api we get the fulfilment status but not the exact time when the order was fulfilled. The fulfilment information from the api is missing.
The fulfilment object in an order has the following properties.
fulfillments: [
{
id: NUMBER,
admin_graphql_api_id: 'gid://shopify/Fulfillment/NUMBER',
created_at: '2022-01-04T11:07:59-05:00',
location_id: NUMBER,
name: 'STRING',
order_id: NUMBER,
receipt: {},
service: 'manual',
shipment_status: null,
status: 'success',
tracking_company: 'ACME',
tracking_number: 'NUMBER',
tracking_numbers: [Array],
tracking_url: 'https://acme.com/TrackConfirmAction?qtc_tLabels1=NUMBER',
tracking_urls: [Array],
updated_at: '2022-01-04T11:08:00-05:00',
line_items: [Array]
}
],
created_at has the information when the fulfilment was created and updated at could have the information when it was even shipped/delivered. How do I get this time, pointers to documentation would be really appreciated.
I am not able to find Stream Chat React-Native documentation for Actions or I am not using what I found correct :-)
I am able to find a message example like:
{
'text': 'Wonderful! Thanks for asking.',
'attachments': [
{
'type': 'form',
'title': 'Select your account',
'actions': [
{
'name': 'account',
'text': 'Checking',
'style': 'primary',
'type': 'button',
'value': 'checking'
},
{
'name': 'account',
'text': 'Saving',
'style': 'default',
'type': 'button',
'value': 'saving'
},
{
'name': 'account',
'text': 'Cancel',
'style': 'default',
'type': 'button',
'value': 'cancel'
}
]
}
]
}
Pushing this message result in a OK rendering in the client.
Image: Message in chat client
However, the React-Native client throws an error when clicking any of the 3 buttons.
The error I get is:
WARN Possible Unhandled Promise Rejection (id: 0):
Error: StreamChat error code 4: RunMessageAction failed with error: "invalid or disabled command ``"
I have found some references to documentation like this:
Actions in combination with attachments can be used to build commands.
But the link does not end up describing anything about Commands.
Anyone have any tip. E.g. like a link to some documentation describing how to make clickable predefined answers work? :-D
I'm trying to use this tool (displaying the results in HTML)
https://github.com/rabbitmq/rabbitmq-perf-test/blob/master/html/README.md
trying to generate messages into topic exchange named: "MYXG.XYZ"
but i just get it into default direct exchange
my json is
cat spec-file.js
[{'name': 'AMQPe',
'type' :'simple',
'uri': 'amqp://guest:guest#192.168.127.23:5672',
'exchange-type': 'topic',
'exchange-name': 'MYXG.XYZ',
'routing-key':'#',
'variables': [{'name': 'min-msg-size', 'values': [3200]}],
'producer-rate-limit': 30000,
'params': [{
'time-limit': 100,
'producer-count': 4,
'consumer-count': 2
}]
}]
can you help?
I am using sails#beta.
I am trying to create several Room models (see definition) below, the problem is that I can successfully create Room models with the same attribute 'name', although attribute 'name' has a unique validation.
The validation isn't detected until the next restart of 'sails' server, then I get this output:
C:\eMali_dev\server>sails lift
info: Starting app...
Express midleware for passport
Waterline encountered a fatal error when trying to perform the `alter` auto-migration strategy.
In a couple of seconds, the data (cached in memory) will be logged to stdout.
(a failsafe put in place to preserve development data)
In the mean time, here's the error:
Error (E_UNKNOWN) :: Encountered an unexpected error:
MongoError: E11000 duplicate key error index: eMali_beta_dev.room.$name_1 dup key: { : "e1" }
Details:
{ error: 'E_UNKNOWN',
summary: 'Encountered an unexpected error',
status: 500,
raw: 'MongoError: E11000 duplicate key error index: eMali_beta_dev.room.$name_1 dup key: { : "e1" }' }
================================
Data backup:
================================
[ { name: 'e1',
center: '53471e2318b931dc1b69f3a8',
min_age: 1,
max_age: 6,
createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
_id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bióc' } },
{ name: 'e2',
center: '53471e2318b931dc1b69f3a8',
min_age: 1,
max_age: 7,
createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
_id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bióª' } },
{ name: 'e1',
center: '53471e2318b931dc1b69f3a8',
min_age: 1,
max_age: 6,
createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
_id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bió«' } } ]
error: A hook (`orm`) failed to load!
Room model:
module.exports = {
schema: true,
attributes: {
name: {
type: 'string',
required: true,
unique: true,
minLength: 3
},
center: {
model: 'center'
},
min_age: {
type: 'integer',
required: true
},
max_age: {
type: 'integer',
required: true
}
}
}
This was a bug in sails and it was fixed. Thanks everybody
You need to change the database from default Disk database to a database of your choice.
I was facing a similar problem and changing database from "Disk" to "MongoDB" fixed my issue.
It seems the default database is unable to enforce unique constraint.
I hope it solves your issue.
Finally after struggling with extjs tree panel, tree store and building custom reader to read and convert pentaho data for 2 weeks I have managed to load pentaho data into treepanel of extjs.
Now my Tree panel is loading same data infinitely.
Treepanel looks as follows :
Part of my json data looks as follows :
{
{name: 'US', candidateCount: 3, children: []},
{name: 'India', candidateCount: 922, children: [
{name: 'Goa', candidateCount:124, children: []},
{name: 'Maharashtra', candidateCount: 43, children: [
{name: 'Pune', candidateCount: 3},
{name: 'Mumbai', candidateCount: 33},
{name: 'Kolhapur', candidateCount: 4},
{name: 'XXX', candidateCount: 3},
]}
]},
{name: 'UK', candidateCount: 1, children: []},
}
As you can see in image above, after expanding India node it has again loaded data of country level (i.e. country names US, uk, India, UK). Actually I want to show state level data like data of Maharashtra, Goa. Instead of that treepanel is again loading same data again.
How to avoid this kind of behavior? I have already set leaf property of US, uk and India nodes to false.
I tried setting Expanded property to true but then treepanel keeps loading same nodes again and again and my browser tab just gets hanged.
Please let me know how to avoid this? I want tree panel to load data only once.
EDIT - Solution to this problem
I solved this problem by adding listener on append event of store and then setting leaf value to true for the nodes which I wanted to be leaf.
I had the same problem with my treepanel and JSON data. My treeStore looks something like this:
proxy: {
type: 'ajax',
url: 'urlJson',
reader: {
type: 'json',
root: 'instanceList',
successProperty: 'success'
}
},
root:{
text: 'Root',
expanded: true
}
And the JSON
{
"instanceList": [
{
"text": "Parent 1",
"instanceList": [
{
"class": "testing",
"id": 3,
"leaf": true,
"text": "Child 1"
}
]
},
{
"text": "Parent 2",
"instanceList": [
{
"class": "testing",
"id": 2,
"leaf": true,
"text": "Child 2"
},
{
"class": "testing",
"id": 1,
"leaf": true,
"text": "Child 3"
}
]
}
],
"instanceTotal": 1,
"success": true
}
I changed "children" for "instanceList" and my treepanel stopped doing that infinitely loop, so I guess If you change "name" for "children" ?
Setting data item to:
{
...
leaf: true
}
will stop it.
Loading trees can be tricking. Try setting loaded: true on those nodes. Before you start clicking around, is the tree properly loaded?
Make sure all parents that do not have any children have "leaf" set to "true" OR
have an empty "children" node.
AND all children nodes have "leaf" set to "true" (as already mentioned by Asken)
it seems to me that any child becomes a root to its dependents . So the root property and the children property MUST have the same NAME. I am very happy I found this tread. It saved my life I was about to shoot myself because of endless reloading the tree
As Edd said, if you set in proxy custom rootProperty:'instanceList', you have to change all "children" in json to that property, ie 'instanceList'. It was my solution.