Пример использования:
objs.sort(sortBy('last_nom'));
Сценарий:
/**
* @description
* Returns a function which will sort an
* array of objects by the given key.
*
* @param {String} key
* @param {Boolean} reverse
* @return {Function}
*/
function sortBy(key, reverse) {
// Move smaller items towards the front
// or back of the array depending on if
// we want to sort the array in reverse
// order or not.
var moveSmaller = reverse ? 1 : -1;
// Move larger items towards the front
// or back of the array depending on if
// we want to sort the array in reverse
// order or not.
var moveLarger = reverse ? -1 : 1;
/**
* @param {*} a
* @param {*} b
* @return {Number}
*/
return function(a, b) {
if (a[key] < b[key]) {
return moveSmaller;
}
if (a[key] > b[key]) {
return moveLarger;
}
return 0;
};
}
Вам необходимо создать базу данных из файла .mdf , а затем использовать драйвер mssql
, чтобы использовать ее с узлом (используйте драйвер mssql
: http://www.tutorialsteacher.com / nodejs / access-sql-server-in-nodejs ).
Создание базы данных из файла .mdf
:
--SQL Script
Create database dbname
On
(
Filename= 'path where you copied .mdf files',
Filename ='path where you copied .ldf log' --Optional
)
For attach;
ИЛИ выполните следующие действия:
.mdf
и .ldf
файл в папку C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\
.MDF
.