2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/frappe/utils.js
2018-01-01 15:15:01 +05:30

24 lines
442 B
JavaScript

module.exports = {
slug(text) {
return text.toLowerCase().replace(/ /g, '_');
},
sqlescape(value) {
if (value===null || value===undefined) {
// null
return 'null';
} else if (value instanceof Date) {
// date
return `'${value.toISOString()}'`;
} else if (typeof value==='string') {
// text
return "'" + value.replace(/'/g, '\'').replace(/"/g, '\"') + "'";
} else {
// number
return value + '';
}
}
}