MCPcopy Create free account
hub / github.com/dwyl/learn-postgresql / insert_person

Function insert_person

server/db.js:52–68  ·  view source on GitHub ↗

* insert_person saves a person's data to the people table. * @param {object} data - a valid JSON object containing data to be inserted. * @param {function} callback - callback function to be executed on success.

(data, callback)

Source from the content-addressed store, hash-verified

50 * @param {function} callback - callback function to be executed on success.
51 */
52function insert_person (data, callback) {
53 connect( function insert_person_after_connected () {
54 const { name, username, bio, worksfor, location, website, uid,
55 stars, followers, following, contribs } = data;
56 const recent_activity = utils.recent_activity(data);
57 const query = `INSERT INTO people (name, username, bio, worksfor, location,
58 website, uid, stars, followers, following, contribs, recent_activity)
59 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`;
60 const values = [name, username, bio, worksfor, location, website, uid,
61 stars, followers, following, contribs, recent_activity];
62
63 PG_CLIENT.query(query, values, function(error, result) {
64 utils.log_error(error, data, new Error().stack);
65 return insert_next_page (data, callback);
66 });
67 });
68}
69
70/**
71 * select_person gets the person from people table.

Callers

nothing calls this directly

Calls 2

connectFunction · 0.85
insert_next_pageFunction · 0.85

Tested by

no test coverage detected