It says it returns an array and each entry contains three pieces of
information. Does each item contain an object with those three
properties?
Can you explain how to do that?
The column names were easy. :-)
Thanks!
Tony Zakula
[ Array ]
+-[0] [ Object ]
| +-[columns] [ Array ]
| | \-[0] log_id
| +-[name] PRIMARY_KEY_B
| \-[unique] true
\-[1] [ Object ]
+-[columns] [ Array ]
| \-[0] event_ts
+-[name] MYNA_LOG__EVENT_TS_IDX_45175
\-[unique] false
Here is an example of how to determine if a unique index on "log_id" exists:
var hasLogIdIndex = t.indexInfo.reduce(function(found,index){
if (found) return found;
if (index.unique){
return index.columns.reduce(function(found,colname){
return colname == "log_id"
},false)
}
return false;
},false)
It seems that "hasIndex(colnames,isUnique)" is an obvious enhancement.
I have added that for the next release. I have also added
Array.prototype.contains(search) which dramatically simplifies the
above code:
hasLogIdIndex = t.indexInfo.contains(function(index){
return index.unique && index.columns.contains("log_id")
})
----------------------------------------------------------
Mark Porter
Myna JavaScript Application Server
Easy web development with server-side JavaScript
http://www.mynajs.org
> --
> You received this message because you are subscribed to the Google Groups "MynaJS-General" group.
> To post to this group, send email to mynajs-...@googlegroups.com.
> To unsubscribe from this group, send email to mynajs-genera...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mynajs-general?hl=en.
>
hasLogIdIndex = t.indexInfo.some(function(index){
return index.unique && index.columns.some(function(name){
return name == "log_id"
})
})
You can use this with "every" to search for indexes with more than one column:
//find a unique index of log_id, and type
hasIndex = t.indexInfo.some(function(index){
return index.unique
&& ["log_id","type"].every(function(targetName){
index.columns.some(function(name){
return name == targetName
})
})
})
I'm keeping the "contains" function because it has a more descriptive
name, and because it allows for a simple form for simple values.
----------------------------------------------------------
Mark Porter
Myna JavaScript Application Server
Easy web development with server-side JavaScript
http://www.mynajs.org
if (columnNames.indexOf("childpagecollection") == -1){
table.addColumn({
name:"childpagecollection",
type:"TEXT"
});
I just committed the changes to Table and Array I talked about.
----------------------------------------------------------
Mark Porter
Myna JavaScript Application Server
Easy web development with server-side JavaScript
http://www.mynajs.org
Tony Zakula