texttoid
v1.0.3
Published
This module convert a text to unique id. Unique ID is autoincrement number. It return always the same number for the same text. Only for Nodejs
Downloads
9
Maintainers
Readme
This module convert a text to unique id. Unique ID is autoincrement number. It return always the same number for the same text. Only for Nodejs
Installation
- $ npm i -g npm
- $ npm init
- $ npm i --save texttoid
DEMO 1
const textToID = require('texttoid')
For Example:
let x = textToID('Hakan Özdaşçı')
console.log(x)
1
let x = textToID('Today is Weater Cold')
console.log(x)
2
If you want to use difference databases
DEMO 2
const textToID = require('texttoid')
For Example:
let x = textToID('İlknur Işık', true, 'documents')
console.log(x)
1
let x = textToID('Today is Weater Cold', true, 'projects')
console.log(x)
1
let x = textToID('Istanbul Metropolitan Municipality', true, 'projects')
console.log(x)
2
If you dont want to a new ID, and then make second parameter false
let x = textToID('Istanbul Metropolitan Municipality', false, 'projects')
console.log(x)
>>> false (cant found id)
>>> 5 (id found)
It gives back always the same ID for the same textes
If you want to a new start for IDs (or remove database)
For Example 1:
let x = textToID('', true, 'documents', 'delete')
console.log(x)
documents removed. Now documents ID will start 1.
For Example 2:
let x = textToID('', true, 'projects', 'delete')
console.log(x)
projects removed. Now projects ID will start 1.
For Example 3: (Remove default database)
let x = textToID('', true, '', 'delete')
console.log(x)
db removed. Now db ID will start 1.