How to add image to user profile in stream.io nodejs? - getstream-io

I'm trying to add an image to my user profile using the below code but it doesn't appear to be working when I run my app. Does anyone know how to properly do this in Node?
client.user('the-user-id').update({
name: "Gwen",
occupation: "Software Engineer",
gender: "female",
image: "https://avatars1.githubusercontent.com/u/1069159?s=400&u=43561f3ac9eda2d28a4fc154443b0ad34ebc5208&v=4"
});

I figured it out, you have to have the profile image named "profileImage" like so:
client.user('the-user-id').update({ name: "Gwen Stafani", occupation: "Software Engineer", gender: "female", profileImage: "https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"});

Related

How to search cases by CompanyId in Netsuite Suitescript 2.0?

I can able to search the case by company name
var mySearch = search.create({
type: search.Type.SUPPORT_CASE,
columns: [{
name: 'title'
}, {
name: 'company'
}],
filters: [{
name: 'company',
operator: 'is',
values: 'Test'
}]
});
return mySearch.run({
ld: mySearch.id
}).getRange({
start: 0,
end: 1000
});
But I am not able to search case by company id.
companyId is 115
Below are not working
i)
filters: [{
name: 'company',
operator: 'is',
values: 115
}]
ii)
filters: [{
name: 'companyid',
operator: 'is',
values: 115
}]
According to the Case schema company is a Text filter, meaning you would have to provide it with the precise Name of the company, not the internal ID.
Instead you may want to use the customer.internalid joined filter to provide the internal ID. Also, Internal ID fields are nearly always Select fields, meaning they do not accept the is operator, but instead require the anyof or noneof operator.
You can find the valid operators by field type on the Help page titled Search Operators
First, you can try this :
var supportcaseSearchObj = search.create({
type: "supportcase",
filters:
[
["company.internalid","anyof","100"]
],
columns:
[
search.createColumn({
name: "casenumber",
sort: search.Sort.ASC
}),
"title",
"company",
"contact",
"stage",
"status",
"profile",
"startdate",
"createddate",
"category",
"assigned",
"priority"
]
});
Second : how did I get this ? The answer is hint that will make your life easier :
Install the "NetSuite Saved Search Code Export" chrome plugin.
In Netsuite UI, create your saved search (it is always easier that doing it in code).
After saving the search, open it again for edition.
At the top right corner (near list, search menu in the netsuite page), you will see a link "Export as script" : click on it and you will get your code ;)
If you can not install the chrome plugin :
In Netsuite UI, create your saved search (it is always easier that doing it in code).
In your code, load your saved search
Add a log.debug to show the [loadedesearchVar].filters
You can then copy what you will see in the log to use it as your search filters.
Good luck!

Unable to enable the input field in react-simple-chatbot NPM module

I imported this module in my react main component and it seems the input field is in disabled mode. Do we need to explicitly enable it . If so which definition should I use it ?
You should mention user: true in steps array object then only it is visible.
steps: [
{
id: "0",
message: "Hey, there! How can I help you?",
trigger: "2"
},
{
id: "2",
user: true,
trigger: "1"
}]

How to implement localisation with HapiJs and MongoDB

MongoDB return the following data:
{
name: {
"en": "any name",
"ar": "اي اسم"
}
}
What can be done, if language chosen is ar and want this output:
{
name: "اي اسم"
}
Thanks!
You can use the aggregation framework built in to MongoDB, e.g.
db.LocalNames.aggregate([
{$match: {"name.ar": {$exists: true}}},
{$project: {"name": "$name.ar"}}
])
This will match only documents with an Arabic name and then project just that value as name

Collections in Hugo data file using Netlify CMS

I'm trying to get my head round using Netlify CMS with Hugo ssg.
I use:
netlify-cms#1.0
hugo#0.29
I have a simple netlify-cms config.yml with two collections: posts and authors.
backend:
name: github
repo: sebhewelt/atlas
branch: master
display_url: https://mypage.com
publish_mode: editorial_workflow
media_folder: "static/uploads"
public_folder: "/uploads"
collections:
- label: "Posts"
name: "post"
folder: "content"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "date", widget: "datetime" , format: "YYYY-MM-DD hh:mma"}
- { label: "Body", name: "body", widget: "markdown" }
- label: "Authors"
name: "author"
folder: "data"
create: true
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "About", name: "about", widget: "string"}
The docs distinguish two collection types, of which I assume i should choose file collection, as I'd like to hold the authors data in one file.
I'd like to be able to add authors via admin dashboard and save it to file in data folder. The docs doesn't provide an example of how should the file holding the authors look like (Or does the cms make it automatically?).
I encounter an error with my current config. When I'm saving the "New Author" i get this:
Failed to persist entry: Error: Collection must have a field name that
is a valid entry identifier
Why do i get this error?
Your authors file needs to be under a top-level collection. Also, if you want to be able to add multiple authors to the file, you need to wrap the "name" and "about" widgets in a "list" type widget.
Example:
collections:
- label: "Settings"
name: "settings"
files:
- name: "authors"
label: "Authors"
file: "data/authors.yml"
extension: "yml"
fields:
- label: "Author"
name: "author"
widget: "list"
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "About", name: "about", widget: "string"}
CMS docs for file collections: https://www.netlifycms.org/docs/collection-types/#file-collections
CMS docs for list widgets: https://www.netlifycms.org/docs/widgets/#list

Using mongodb, how can I remove an object from an array based on one of its properties?

I have a mongodb collection containing an array of objects, and I'd like to remove one or more of the array objects based on their properties.
Example document from my collection:
nickname: "Bob",
isLibrarian: false,
region: "South America",
favoriteBooks: [
{
title: "Treasure Island",
author: "Robert Louis Stevenson"
},
{
title: "The Great Gatsby",
author: "F. Scott Fitzgerald"
},
{
title: "Kidnapped",
author: "Robert Louis Stevenson"
}
]
In this example, how do I remove, from each of the documents in my collection, all objects within the favoriteBook array whose author matches "Robert Louis Stevenson"?
So that afterwards this user document would be
nickname: "Bob",
isLibrarian: false,
region: "South America",
favoriteBooks: [
{
title: "The Great Gatsby",
author: "F. Scott Fitzgerald"
}
]
and other documents in the collection would be equally trimmed of books by Stevenson.
Thank you in advance for any insight! I love MongoDB but I'm wondering if I've bitten off more than I can chew here...
The below line of mongodb will help you to delete the books that matches a particular author
db.collection.update(
{},
{$pull:{favoriteBooks:{author:"Robert Louis Stevenson"}}},
{multi:true}
);

Resources