SHARE
TWEET

This shit if flexible af

a guest Aug 12th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3. //Function for making query that will input object into. Currently just prints object propeties into sting.
  4. function add(crudObject){
  5.     let SQLquery = "";
  6.     for (let property in crudObject) {
  7.         //if (crudObject.hasOwnProperty(property)) {
  8.             SQLquery += property + " = " + crudObject[property].value + " | ";
  9.         //}
  10.     }
  11.     return SQLquery;
  12. }
  13.  
  14.  
  15. //Pure profile field blueprint. Adding new propeties, adds new propeties for every single profile field.
  16. const userFieldPrototype = {
  17.     name: "",
  18.     displayName: "",
  19.     value: ""
  20. }
  21.  
  22.  
  23. //////////////////////////////////
  24.  
  25. //List of fields in user profile
  26. let userFields = [];
  27.  
  28. let tempObj = {name: "username", displayName: "Username"} //Creates new object
  29. tempObj.__proto__ = userFieldPrototype; //Inherits from userFieldPrototype
  30. userFields[ tempObj.name ] = tempObj; //Assigns newly created field to array
  31.  
  32. tempObj = {name: "password", displayName: "Password"};
  33. tempObj.__proto__ = userFieldPrototype;
  34. userFields[ tempObj.name ] = tempObj;
  35.  
  36. tempObj = {name: "permissions", displayName: "Permissions"};
  37. tempObj.__proto__ = userFieldPrototype;
  38. userFields[ tempObj.name ] = tempObj;
  39.  
  40.  
  41. //Pure user blueprint. Adding new propeties, adds new propeties for every single user profile.
  42. const userPrototype = {
  43.     username: userFields["username"],
  44.     password: userFields["password"],
  45.     permissions: userFields["permissions"]
  46. }
  47.  
  48.  
  49. ///////////////////////////
  50. let myUser = new Object();
  51. myUser.__proto__= userPrototype;
  52. myUser["username"].value = "Bogdan";
  53. myUser["password"].value = "Bogdan69";
  54. myUser["permissions"].value = "AA BS AS";
  55.  
  56. //Shows query for adding new user.
  57. console.log( add(myUser) );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top