Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cassandra = require('cassandra-driver');
- //const Uuid = require('cassandra-driver').types.Uuid;
- const Integer = require('cassandra-driver').types.Integer;
- const client = new cassandra.Client({ contactPoints: ['127.0.0.1'],
- keyspace: 'my_music', localDataCenter: 'datacenter1'});
- client.connect(function (err) {
- if (err) return console.error(err);
- console.log('Connected to cluster with %d host(s): %j',
- client.hosts.length, client.hosts.keys());
- });
- function startTheSongs(user_email, album_id, lp)
- {
- var user_email, album_id, title, lp, artistSong, albumTitleSong;
- //const albumId = Uuid.fromString(album_id);
- console.log(album_id + ' To jest id z glownej funkcji');
- const Uuid = require('cassandra-driver').types.Uuid;
- const albumId = Uuid.fromString(album_id);
- const Integer = require('cassandra-driver').types.Integer;
- console.log(albumId instanceof Uuid);
- console.log(typeof(lp) + ' to jest ' + lp);
- const lpSong = Integer.fromNumber(lp);
- console.log(lpSong instanceof Integer);
- // dane do sprawdzenia id_433fb540-848b-11e9-8d93-fb8cf387b215, lp = 9 == Brothers in Arms
- function getSongTitle(album_id, lp){
- const queryGetTitleSong = 'SELECT title FROM songs WHERE album_id = ? AND lp = ?';
- const paramsGetTitleSong = [albumId, lpSong];
- console.log(lp instanceof Integer);
- console.log(album_id instanceof Uuid);
- console.log(typeof(album_id) + ' to jest ' + album_id);
- console.log(typeof(lp) + ' to jest ' + lp);
- return new Promise(function(resolve, reject){
- client.execute(queryGetTitleSong, paramsGetTitleSong, { prepare: true })
- .then((result) => result.rows[0])
- .catch(err => {
- console.log(err);
- return 'jest ok' // obsluguję blad
- });
- });
- }
- getSongTitle()
- .then(res => {
- console.log(res);
- })
- .catch(err => console.log(err));
- }
- //startTheSongs('oracle@example.com', '60485090-debc-11e8-a218-eda19fa33fe9', 1);
- startTheSongs('oracle@example.com','602908c0-debc-11e8-a218-eda19fa33fe9', 5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement