I might be getting this wrong, but just to check, you aren't planning on using https://github.com/commandprompt/postgres-js on a client/user-facing website are you? It looks like it connects with a password provided, which means you'd be supplying the user with your db password!
All you need to store points that the user clicks is a backend that can insert data as Aragon said, and a simple PUT to e.g. a flask app -
Front end:
map = L.Map(...);
map.on('click', function(e) {
$.ajax('someurl/putpoint/', {
type: 'PUT',
data: {
lat: e.latlng.lat,
lng: e.latlng.lng
}
});
});
Back end with e.g. http://flask.pocoo.org/ :
from flask import Flask
app = Flask(__name__)
@app.route('/someurl/putpoint/')
def putpoint():
cursor = get_your_db_cursor()
# NB: massively insecure accepting any random input from PUT!
# Should use the params arg in execute() rather than format str
cursor.execute("""
INSERT INTO test(p_id, the_geom)
VALUES(2, ST_GeomFromText('POINT(%s %s)', 4326));""" % (
request.form['lng'], request.form['lat']))
if __name__ == '__main__':
app.run()