$substr doesnt work on mongodb compass community - sql

I have a collection and i want to show like some characteres from "categoria" which is inside "Problema", but it keeps giving me this error, and i have searched alot and i think everything is correct, any help?

In order to use $substr you will need to use an aggregation
I tried the aggregation tool in Compass, but it is not clear to me.
However, I tried this aggregation with one collection:
db.getCollection('products').aggregate(
[
{
$project:
{
tex: { $substr: ["$name",2,7] }
}
}
])

Related

What is the current `map()` doing?

( Gun.version 0.9.6 )
Given the following data structure
{
lights:{
1:{
state:{
on:true,
color:'red',
br:254
}
},
2:{
state:{
on:true,
color:'red',
br:254
}
},
3:{
state:{
on:true,
color:'red',
br:254
}
}
}
}
I want to turn the lights on/off at the same time.
gun.get('lights').val(cb) does give me {1:{...},2:{...},3:{...}} and gun.get('lights').path('1.state.on').put(false); works perfect.
I thought that by doing gun.get('lights').map().path('1.state.on').put(false) it would 'map' over all lights but instead it only changes the first light.
Question: How do i turn on/off all the lights ?
#stef-de-vries , you've spotted an important TODO bug in gun's source code!
Currently (v0.9.6), put does not work with map() commands. I think it only picks the first item (which may be random) and then turns it off.
This is bad, and needs to be addressed.
For now, the work around is to probably do something like:
gun.get('lights').map().path('state.on').val(function(){
this.put(false);
});
Which is ugly.
Hmm.. okay, but it fails on gun.get('lights').map().val(cb) also if i run it the second time.
Solved my problem with the each() module
gun.get('lights').each(node=>{
gun.get(node._['#']).path('state.on').put(true)
})

Displaying Only Certain Columns/Properties with Keen DataViz

I'm wondering how to display only certain columns on my table when I'm trying to do data visualization. Right now, every time that I do a table, it shows every single property or column. I tried to figure out how to only show certain columns properties by guessing based on the documentation for extraction within the keen.io docs (I've commented out my wrong guess)
var foo = new Keen.Query("extraction", {
eventCollection: "Purchases",
targetProperty: "zip",
// I've commented out line 7 because it doesn't work, it was just my guess on syntax...
// how do I only show certain columns of the table (columns are properties)
// vs. showing the entire table?
// propertyNames: ["zip","businessname"]
filters: [
{
"property_name" : "zip",
"operator" : "eq",
"property_value" : "80016"
},
{
"property_name" : "city",
"operator" : "eq",
"property_value" : "Aurora"
}]
});
client.draw(foo, document.getElementById("chart-09"), {
chartType: "table",
title: "Table"
});
https://gist.github.com/mrtannerjones/ba0cbd7340f2e016fcf2 - here is a link to the above code except on github in case something isn't formatted correctly.
Sorry if this question seems terribly basic or simple, I'm still really new at learning how to code.
Found the fix with a little help from David in the Keen.io Google group. I actually was just missing a comma after the 'property names', but what's more interesting to me is that the data visualization works with both camel case and with underscore separators. property_names and propertyNames both seem to work.

How to add percent done by story count to cardboard

I am struggling to incorporate the percent done by story count into a kanban board I have built (kanban of portfolio items.) I was tried working off of:
https://github.com/RallyApps/PortfolioKanban
but I could not quite figure out how to incorporate the percent done by story count aspect. Anyone know of a simple way to add this to each of the cards?
There are two paces in the PortfolioKanbanApp.js where PercentDoneByStoryCount is referenced:
config: {
defaultSettings: {
fields: 'PercentDoneByStoryCount'
}
},
and
_attachPercentDoneToolTip:function (cardboard) {
Ext.create('Rally.ui.tooltip.PercentDoneToolTip', {
target:cardboard.getEl(),
delegate:'.percentDoneContainer',
percentDoneName: 'PercentDoneByStoryCount',
//...

Yii: Best Performance Benificial way to include JS/Ajax functions in CGridview

Yii newbie here
I have tried more than once to figure out a way to include an Ajax/JS function in an easy clean way in my CGRIDVIEW,
the code is basically
'click'=> "function (){
$.fn.yiiGridView.update('news-grid', {
type:'POST',
url:$(this).attr('href'),
success:function(data) {
$('#AjFlash').html(data).fadeIn().animate({
opacity: 1.0
}, 3000).fadeOut('slow');
$.fn.yiiGridView.update('news-grid');
}
})
return false;
}"
In your opinion, whats the cleanest, most performance benificial way to include this?
Thank you for your time !!!
I don't know but I dont see necesary to force the grid to update twice on a single operation, I also don't like to include my javascript like that. Depending on what I need there are several approaches, for the sake of this answer ill show you the easiest one:
Create a global object, in a separate file:
//app.js
var App = {
updateSomething: function () {
$.post(
$(this).attr('href'),
success:function(data) {
$('#AjFlash').html(data).fadeIn().animate({
opacity: 1.0
}, 3000).fadeOut('slow');
$.fn.yiiGridView.update('news-grid');
}
);
return false;
}
};
And the you can include that file from your controller by calling CCLientScript::registerScriptFile
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl."js/app.js");
And on your grid:
'click'=> "js:App.updateSomething",
There are much better approaches, but this is the more simple for js beginners that want to have some kind of organization.

How To Get The TotalPage of a store?

In My Program I'am Using Grid Pagination. In a particular situvation I need the totalPage
count of a store.Any Way To Get it?
Please Help Me....
Your server should send back the total number of records, something like this:
{
success:true,
total:999,
records:[
{
id:1,
name:'Arundev PV'
}
]
}
then you can use store.getTotalCount() to get that value.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-getTotalCount
you can customize the name of the "total" property with
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader-cfg-totalProperty