bootstrap3 datetimepicker cannot load the locale - ruby-on-rails-4

(Using Rails 4 ) I am trying to display the bootstrap3 datetimepicker in the current locale , it's working fine in english , but when I try to insert the require locale file in the application.js ( as stated in the doc) , I get an error :
[Error] TypeError: undefined is not an object (evaluating '$.fn.datetimepicker.dates')
(anonymous function) (application.js, line 15026)
in my assets, the application.js , I have :
//= require jquery
//= require jquery_ujs
//= require bootstrap.min
//= require moment
//= require bootstrap-datetimepicker
//= require pickers
// You may include any languages (optional)
//= require locales/bootstrap-datetimepicker.fr
the bootstrap-datetimepicker.fr.js file is the following :
;(function($){
$.fn.datetimepicker.dates['fr'] = {
days: ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
daysShort: ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"],
daysMin: ["D", "L", "Ma", "Me", "J", "V", "S", "D"],
months: ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"],
today: "Aujourd'hui"
};
}(jQuery));
maybe this javascript content is not right... but why ? or is there another issue ?
problem is not with the datetimepicker as it's displayed correctly in english ( default)

withe this latest version, using moments.js ... I SHOUDL use the moments locales !!!
so my bootstrap-datetimepicker.fr.js should be :
// moment.js locale configuration
// locale : french (fr)
// author : John Fischer : https://github.com/jfroffice
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
module.exports = factory(require('../moment')); // Node
} else {
factory(window.moment); // Browser global
}
}(function (moment) {
return moment.defineLocale('fr', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
longDateFormat : {
LT : 'HH:mm',
L : 'DD/MM/YYYY',
LL : 'D MMMM YYYY',
LLL : 'D MMMM YYYY LT',
LLLL : 'dddd D MMMM YYYY LT'
},
calendar : {
sameDay: '[Aujourd\'hui à] LT',
nextDay: '[Demain à] LT',
nextWeek: 'dddd [à] LT',
lastDay: '[Hier à] LT',
lastWeek: 'dddd [dernier à] LT',
sameElse: 'L'
},
relativeTime : {
future : 'dans %s',
past : 'il y a %s',
s : 'quelques secondes',
m : 'une minute',
mm : '%d minutes',
h : 'une heure',
hh : '%d heures',
d : 'un jour',
dd : '%d jours',
M : 'un mois',
MM : '%d mois',
y : 'un an',
yy : '%d ans'
},
ordinal : function (number) {
return number + (number === 1 ? 'er' : '');
},
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4th is the first week of the year.
}
});
}));

Related

elasticsearch-dsl-py query filter with term and range

I'm trying to filter a query with term and range along with query-string. filter(range) and query string works but not filter(term). am i doing something wrong?
es = Elasticsearch([{'host': '192.168.121.121', 'port': 9200}])
index = Index("filebeat-*",using=es)
search = index.search()
searchStr = "OutOfMemoryError"
search = search.query("query_string", query=searchStr)
search = search.filter('range' , **{'#timestamp': {'gte': 1589399137000 , 'lt': 1589399377000, 'format' : 'epoch_millis'}})
search = search.filter('term' , **{'can.deployment': 'can-*' })
response = search.execute(ignore_cache=True)
print(response.hits.total)
print(response.hits.hits._source.can.deployment)
json:
filter-term - ['hits']['hits']['_source']['can']['deployment']
filter-range- ['hits']['hits']['_source']['#timestamp']
{
"hits" : {
"total" : 138351328,
"max_score" : 6.5700893,
"hits" : [
{
"_index" : "filebeat-6.1.2-2020.05.13",
"_type" : "doc",
"_score" : 2.0166037,
"_source" : {
"#timestamp" : "2020-05-13T01:14:03.354Z",
"source" : "/var/log/gw_rest/gw_rest.log",
"message" : "[2020-05-13 01:14:03.354] WARN can_gw_rest [EventLoopGroup-3-2]: An exceptionCaught() event was fired.OutOfMemoryError,
"fileset" : {...},
"can" : {
"level" : "WARN",
>>>>>>>> "message" : "An exceptionCaught() event was fired- OutOfMemoryError,
"timestamp" : "2020-05-13 01:14:03.354",
>>>>>>>> "deployment" : "can-6b721b93965b-w3we4-4074-9903"
}
}
}
]
}
}
I actually didn't need a filter(term). this worked:
dIds=response['hits']['hits'][1]['_source']['can']['deployment']
print(dIds)
#loop through the response
for i in response['hits']['hits']:
id = i['_source']['can']['deployment']
print(id)

Tabulator highlight entries on data refresh

I have a tabulator table used to display statistics from live football matches, the table is updated every 60 seconds using the following function
setInterval(function(){
selectedtableData = table.getSelectedRows();
table.replaceData()
.then(function(){
var f;var filterarray= [];
for (f = 0; f < selectedtableData.length; f++) {
var rowIndex = selectedtableData[f].getIndex();
table.selectRow(rowIndex);
}
})
.catch(function(error){
//handle error loading data
});
}, 60000);
I allow users to highlight rows so this function saves the rows on refresh and refreshdata updates the table
The table is fairly standard stuff using icons for headers to conserve space and is refreshed from a Json file
var table = new Tabulator("#example-table", {
layout:"fitColumns",
ajaxURL:"../new/console.json",
// ajaxURL:"console.json",
height:800,
groupBy:"league",
paginationSize:100,
selectable:true,
index:"matchid",
selectablePersistence:true,
columns:[
{field:"",
columns:[
{width:5,headerSort:false},
{formatter:"rowSelection", titleFormatter:"rowSelection", align:"center", headerSort:false,width:10},
{title:"league", field:"league",width:5,headerSort:false,visible:false,formatter:"html"},
{title:"img/clock2.png", field:"time", sorter:"date",width:40,titleFormatter:"image",headerSort:false,headerTooltip:"Time gone"},
{title:"img/goal2.png", field:"score", sorter:"string",width:40,formatter:"html",align:"center",headerSort:false,titleFormatter:"image",headerTooltip:"Current Score"},
{headerFilter:true,title:"Teams",field:"team",headerSort:false, formatter:"html",width:160},
{title:"timep", field:"timep",visible:false},
{title:"matchid", field:"matchid",visible:false},
{title:"totalap1", field:"totalap1",visible:false},
{title:"draw", field:"draw",visible:false},
{title:"homescore", field:"homescore",visible:false},
{title:"awayscore", field:"awayscore",visible:false},
{title:"homecorners", field:"homecorners",visible:false},
{title:"awaycorners", field:"awaycorners",visible:false},
{title:"homesont", field:"homesont",visible:false},
{title:"awaysont", field:"awaysont",visible:false},
{title:"homesoft", field:"homesoft",visible:false},
{title:"awaysoft", field:"awaysoft",visible:false},
{title:"homeposs", field:"homeposs",visible:false},
{title:"awayposs", field:"awayposs",visible:false},
{title:"homeda", field:"homeda",visible:false},
{title:"awayda", field:"awayda",visible:false},
{title:"homelp", field:"homelp",visible:false},
{title:"awaylp", field:"awaylp",visible:false},
{title:"homeyc", field:"homeyc",visible:false},
{title:"awayyc", field:"awayyc",visible:false},
{title:"homerc", field:"homerc",visible:false},
{title:"awayrc", field:"awayrc",visible:false},
{title:"homet", field:"homet",visible:false},
{title:"awayt", field:"awayt",visible:false},
{title:"img/pressure2.png",field:"pi1",width:30,formatter:"html",titleFormatter:"image",headerClick:ap1sort,headerSort:false,align:"center",headerTooltip:"Attacking Pressure1",
cellMouseEnter:function(e, cell, row){var row=cell.getRow().getData();
var celldata=cell.getElement();if (!celldata._tippy){tippy(celldata, { content: "Attacking Pressure <iframe style=\"background:#FFFFFF;\" src=\"../pressure/showgraph.php?gameid="+row.matchid+"&pi=pi1&time="+row.timep+"\" width=420 height=225></iframe>",maxWidth:"450px",a11y: false,arrow:true,
})}celldata._tippy.show();}},
{title:"img/pressure2.png",field:"pi2",width:30,formatter:"html",headerSort:false,titleFormatter:"image",headerTooltip:"Attacking Pressure2",
cellMouseEnter:function(e, cell, row){var row=cell.getRow().getData();
var celldata=cell.getElement();if (!celldata._tippy){tippy(celldata, { content: "Attacking Pressure 2 <iframe style=\"background:#FFFFFF;\" src=\"../pressure/showgraph.php?gameid="+row.matchid+"&pi=pi2&time="+row.timep+"\" width=420 height=225></iframe>",maxWidth:"450px",a11y: false,arrow:true,
})}celldata._tippy.show();}},
{title:"img/poss.png", field:"poss",headerSort:false,headerTooltip:"possesion",width:50,formatter:"html",titleFormatter:"image"},
{title:"img/soont.png" , field:"shotsont", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",headerTooltip:"Shots on Target"},
{title:"img/sooft.png" , field:"shotofft", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",headerTooltip:"Shots off Target"},
{title:"img/shotsinbox.png" , field:"sinbox", width:40,titleFormatter:"image",headerTooltip:"Shots in the Box",headerSort:false,align:"center",formatter:"html",headerTooltip:"Shots in the Box"},
{title:"img/dattacks.png" , field:"dattack", sorter:"number", width:60,headerSort:false,align:"center",titleFormatter:"image",formatter:"html",headerTooltip:"Dangerous attacks"},
{title:"img/attacks.png" , field:"attack", sorter:"number", width:60,headerSort:false,align:"center",titleFormatter:"image",formatter:"html",headerTooltip:"Attacks"},
{title:"img/corner.png" , field:"corners", width:40,titleFormatter:"image",headerTooltip:"Corners",headerSort:false,align:"center",formatter:"html",headerTooltip:"Corners"},
{title:"img/foul.png" , field:"fouls", width:40,headerSort:false,align:"center",formatter:"html",titleFormatter:"image",headerTooltip:"Fouls"},
{title:"img/ycard.png" , field:"ycards", width:30 ,titleFormatter:"image",headerTooltip:"Yellow Card",headerSort:false,align:"center",formatter:"html"},
{title:"img/rcard.png" , field:"rcards", width:30 ,titleFormatter:"image",headerTooltip:"Red Card",headerSort:false,align:"center",formatter:"html"},
{title:"img/form.png", field:"form",headerSort:false,headerTooltip:"form",formatter:"html",width:100,align:"center",titleFormatter:"image",
cellMouseEnter:function(e, cell, row){var row=cell.getRow().getData();
var celldata=cell.getElement();if (!celldata._tippy){tippy(celldata, { content: "% Stats are based on the last 5 games<iframe style=\"background:#FFFFFF;\" src=\"../stats/games/"+today+"/"+row.matchid+".html\" width=620 height=225</iframe>",maxWidth:"650px",a11y: false,arrow:true,
})}celldata._tippy.show();}},
]},
{title:"Previous 10 mins",
columns:[
{title:"img/poss.png", field:"10poss",headerSort:false,headerTooltip:"Possesion - Last 10 mins",width:74,formatter:"html",titleFormatter:"image"},
{title:"img/soont.png" , field:"10shotsont", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",headerTooltip:"Shots on Target - Last 10 mins"},
{title:"img/sooft.png" , field:"10shotofft", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",headerTooltip:"Shots off Target - Last 10 mins"},
{title:"img/dattacks.png" , field:"10dattack", sorter:"number", width:55,headerSort:false,align:"center",titleFormatter:"image",formatter:"html",headerTooltip:"Dangerous attacks - Last 10 mins"},
{title:"img/corner.png" , field:"10corners", width:30,titleFormatter:"image",headerTooltip:"Corners",headerSort:false,align:"center",formatter:"html",headerTooltip:"Corners - Last 10 mins"},
]},
{title:"Previous 5 mins",
columns:[
{title:"img/poss.png", field:"5poss",headerSort:false,headerTooltip:"Possesion - Last 5 mins",width:74,formatter:"html",titleFormatter:"image",visible:false},
{title:"img/soont.png" , field:"5shotsont", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",visible:false,headerTooltip:"Shots on Target - Last 5 mins"},
{title:"img/sooft.png" , field:"5shotofft", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",visible:false,headerTooltip:"Shots off Target - Last 5 mins"},
{title:"img/dattacks.png" , field:"5dattack", sorter:"number", width:55,headerSort:false,align:"center",titleFormatter:"image",formatter:"html",visible:false,headerTooltip:"Dangerous attacks - Last 5 mins"},
{title:"img/corner.png" , field:"5corners", width:30,titleFormatter:"image",headerTooltip:"Corners",headerSort:false,align:"center",formatter:"html",visible:false,headerTooltip:"Corners - Last 5 mins"},
]},
{title:"Previous 20 mins",
columns:[
{title:"img/poss.png", field:"20poss",headerSort:false,headerTooltip:"Possesion - Last 20 mins",width:74,formatter:"html",titleFormatter:"image",visible:false},
{title:"img/soont.png" , field:"20shotsont", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",visible:false,headerTooltip:"Shots on Target - Last 20 mins"},
{title:"img/sooft.png" , field:"20shotofft", sorter:"number", width:45,align:"center",headerSort:false,titleFormatter:"image",formatter:"html",visible:false,headerTooltip:"Shots off Target - Last 20 mins"},
{title:"img/dattacks.png" , field:"20dattack", sorter:"number", width:55,headerSort:false,align:"center",titleFormatter:"image",formatter:"html",visible:false,headerTooltip:"Dangerous attacks - Last 20 mins"},
{title:"img/corner.png" , field:"20corners", width:30,titleFormatter:"image",headerTooltip:"Corners",headerSort:false,align:"center",formatter:"html",visible:false,headerTooltip:"Corners - Last 20 mins"},
]},],
}
) };
The datafile is a simple Json file, it can contain 300+ nodes or just one depening on how many games are ongoing
{
"league" : "<img src=flags/iran.png> Iran :- Azadegan League",
"time" : "90+",
"selectmh" : "",
"timep" : "90",
"matchid" : "1084ED7",
"team" : "Mes Rafsanjan FC(3)<br>Sepidrood Rasht(16)",
"score" : "<b>1<br>0</b>",
"homescore" : "1",
"awayscore" : "0",
"totalg" : "1",
"totalshot" : "0",
"totalshotot" : "0",
"totalda" : "0",
"totalco" : "0",
"totalshotib" : "0",
"scorediff" : "1",
"homecorners" : "0",
"awaycorners" : "0",
"homesont" : "0",
"awaysont" : "0",
"homesoft" : "0",
"awaysoft" : "0",
"homeposs" : "0",
"awayposs" : "0",
"homeda" : "0",
"awayda" : "0",
"homelp" : "3",
"awaylp" : "16",
"homeyc" : "0",
"awayyc" : "0",
"homerc" : "0",
"awayrc" : "0",
"homet" : "Mes Rafsanjan FC",
"awayt" : "Sepidrood Rasht",
"activity" : "",
"pi1" : "0<br>10",
"pi2" : "1<br>1",
"hpi1" : "0",
"api1" : "10",
"hpi2" : "1",
"api2" : "1",
"poss" : "0%<br>0%",
"sinbox" : "0<br>0",
"shotsont" : "0<br>0",
"shotofft" : "0<br>0",
"corners" : "0<br>0",
"dattack" : "0<br>0",
"attack" : "0<br>0",
"fouls" : "0<br>0",
"ycards" : "0<br>0",
"rcards" : "0<br>0",
"10poss" : "0%<br>0%",
"10hshotsont" : "0",
"10ashotsont" : "1",
"10tshotsont" : "1",
"5tshotsont" : "0",
"20tshotsont" : "1",
"5shotofftt" : "0",
"5cornert" : "0",
"10shotofftt" : "0",
"10cornert" : "0",
"10shotsont" : "0<br><span class=away>1</span>",
"10shotofft" : "0<br>0",
"10corners" : "0<br>0",
"10dattack" : "2<br>2",
"20hshotsont" : "0",
"20ashotsont" : "1",
"20poss" : "0%<br>0%",
"20shotsont" : "0<br><span class=away>1</span>",
"20shotofft" : "0<br>0",
"20corners" : "0<br>0",
"20dattack" : "13<br>9",
"5hshotsont" : "0",
"5ashotsont" : "0",
"5poss" : "0%<br>0%",
"5shotsont" : "0<br>0",
"5shotofft" : "0<br>0",
"5corners" : "0<br>0",
"5dattack" : "0<br>0",
"form" : "<span class=d>D</Span><span class=lost>L</Span><span class=w>W</Span><span class=w>W</Span><span class=w>W</Span><br><span class=lost>L</Span><span class=lost>L</Span><span class=lost>L</Span><span class=lost>L</Span><span class=lost>L</Span>",
"draw" : "0",
"totalap1" : "10"}
As the data refreshes the score can change and I want to highlight this, I could do it in the source json file by adding some CSS attributes to highlight it but as time is critical in this app then this would be an extra comparsion and I would need to store the previuos score somewhere and retrieve it, is there any function I can use in Tabulator to apply some CSS automatically if the values have changed from the previous refresh
Hope that all makes sense
So I eventually solved this outside of tabulator, I have a php script which creates the JSON tabulator reads, in this file I compared the last score with the current score, if they matched I set a JSON variable , then in tabulator i made this Varibale non visible and added a row formatter function to the score. So my variable is gs (goal scored) and I set this to 1 if a goal has been scored
{title:"img/goal2.png", field:"score", sorter:"string",width:40,align:"center",headerSort:false,titleFormatter:"image",headerTooltip:"Current Score",formatter:function(row,cell, formatterParams, onRendered){
var data = row.getData();
if (data.gs==1)
{var score2= '<span class="blinking">'+data.score+'</span>';}
else
{var score2=data.score;}
return score2;
},},
I then added some css
.blinking{
animation:blinkingText 1.2s infinite;
}
#keyframes blinkingText{
0%{ color: #FF0000; }
49%{ color: #FF0000; }
60%{ color: transparent; }
99%{ color:transparent; }
100%{ color: #FF0000; }
}
The data updates every 30 seconds so the blink effect is set to infinite and is then overwritten
probably not the neatest way to do it but it works

Mongo DB searching for occurances by date

So I've got a large dataset stored in my MonogDB of each time a song has been played in my itunes library, so each document is contains the artist name, song name, and date/time it was played. I currently am able to use the following query to search for the most occurances of a song in the database, which basically gives me the total number of times i had played it:
db.apple.aggregate([{ $sortByCount: "$song" }])
Returns:
{ "_id" : "Fireflies (feat. Grieves)", "count" : 336 }
{ "_id" : "Cinderella (feat. Ty Dolla $ign)", "count" : 267 }
{ "_id" : "Check", "count" : 241 }
{ "_id" : "100 Grandkids", "count" : 240 }
{ "_id" : "Late For the Sky (feat. Slug & Aesop Rock)", "count" : 226 }
This returns the total number of plays i have on a song, over the 5 years of plays i have in the database. What i was hoping to be able to do is create a query where it returns the total number of plays of a song for a specific year. I have the following query:
db.apple.find({"playTime" : {$regex : ".*2019*"}}).pretty()
This one returns all the songs that were played in a year but i can't figure out how i would combine these two queries.
Assuming playTime is a string data type ({ "playTime" : "2017-06-17T06:04:40.230Z" }), extract the first 4 characters of the string using the $substrCP and convert to an integer and match with an input year. The $sortByCount stage will remain as it is. The conversion to integer is optional; if not used the input year should be a string.
For example (using integer year):
var INPUT_YEAR = 2017
db.test.aggregate( [
{
$match: {
$expr: {
$eq: [ INPUT_YEAR, { $toInt: { $substrCP: [ "$playTime", 0, 4 ] } } ]
}
}
},
{
$sortByCount: "$song"
}
] )
Since you already have the queries ready, you just need to put them both in the same aggregation pipeline as JBone suggested in the comments. If your queries work as you have mentioned, this will do the trick:
db.apple.aggregate([
{ $sortByCount: "$song" },
{ $match: { "playTime" : {$regex : ".*2019*"} } }
])
If playTime is a string of type ISO 8601 format, then you can try this :
db.apple.aggregate([{
$match: {
$expr: {
$eq: [2019, {
$year: {
$dateFromString: {
dateString: '$playTime'
}
}
}]
}
}
}, { $sortByCount: "$song" }])
Or in case if you can change it to/have ISODate() then :
db.apple.aggregate([{
$match: {
$expr: {
$eq: [2019, {
$year: '$playTime'
}]
}
}
}, { $sortByCount: "$song" }])
Ref : $year,$dateFromString,$match or $isoWeekYear

Regex in Mongodb for ISO Date field

How can I pick all the dates with time value as 00:00:00 despite the date value? Regex doesn't work for me.
{
"_id" : ObjectId("59115a92bbf6401d4455eb21"),
"name" : "sfdfsdfsf",
"create_date" : ISODate("2013-05-13T02:34:23.000Z"),
}
something like :
db.myCollection.find({"create_date": /*T00:00:00.000Z/ })
You need to first convert created date into string of time, and if time is 00:00:00:000, then include the document.
db.test.aggregate([
// Part 1: Project all fields and add timeCriteria field that contain only time(will be used to match 00:00:00:000 time)
{
$project: {
_id: 1,
name: "$name",
create_date: "$create_date",
timeCriteria: {
$dateToString: {
format: "%H:%M:%S:%L",
date: "$create_date"
}
}
}
},
// Part 2: match the time
{
$match: {
timeCriteria: {
$eq: "00:00:00:000"
}
}
},
// Part 3: re-project document, to exclude timeCriteria field.
{
$project: {
_id: 1,
name: "$name",
create_date: "$create_date"
}
}
]);
From MongoDB version >= 4.4 we can write custom filters using $function operator.
Note: Donot forget to chage the timezone to your requirement. Timezone is not mandatory.
let timeRegex = /.*T00:00:00.000Z$/i;
db.myCollection.find({
$expr: {
$function: {
body: function (createDate, timeRegex) {
return timeRegex.test(createDate);
},
args: [{ $dateToString: { date: "$create_date", timezone: "+0530" } }, timeRegex],
lang: "js"
}
}
});

How to search and replace in mongoose?

My objective :I want to update multiple documents in a collection in a certain path with a condition that path matches a regex then search and replace with certain value in the path then finally save all those documents persistently in db.
example:
myCollection : [
{ doc1 : { summary : 'Summary 1 : one', value : 1 },
{ doc2 : { summary : 'Summaryyuist 2 : two', value : 1 },
{ doc3 : { summary : 'hello 3 : three', value : 3 },
];
now i want to replace all 'Summary' with 'hello' in path :'summary'
so the result after query should be :
myCollection : [
{ doc1 : { summary : 'hello 1 : one', value : 1 },
{ doc2 : { summary : 'helloyuist 2 : two', value : 1 },
{ doc3 : { summary : 'hello 3 : three', value : 3 },
];
I am just looking the query to be used above.
From here
http://mongoosejs.com/docs/api.html#query_Query-regex
I found no information how to implement. Specially what the 'Number' parameter does in regex method.?
Also from here :
http://mongoosejs.com/docs/api.html#query_Query-regex
Also i do not found the 'show code' link for monsoose regex. Can someone at least reply a link for mongoose regex code.
i find only how to find models, NOT how to update with replacement with a value that matches the regex in certain path of docs.
How to achieve my objective?
You could use mongoose Model.Update option i hope.
Model.update = function (query, doc, options, callback) { ... }
Example :
MyModel.update({ age: { $gt: 18 } }, { oldEnough: true }, fn);
MyModel.update({ name: 'Tobi' }, { ferret: true }, { multi: true }, function(err,numberAffected, raw) {
if (err) return handleError(err);
console.log('The number of updated documents was %d', numberAffected);
console.log('The raw response from Mongo was ', raw);
});
http://mongoosejs.com/docs/api.html#model_Model.update