1

Need better solution for migration.

Description: Service for user mail address verification.

Problem: Business logic stored in pl/pgSQL procedures in Postgres.

Steps:

1. Insert into table user Email address and randomly generated hash

2. Send verification/confirmation Email with URL path and hash argument

3. Recv HTTP request with hash:
    hash equals - Update record: CONFIRMED, return success
    hash not found - Return error

4. Send response (error or success HTML page)

Details with servlet logic (Steps 3,4):

-Servlet call pl/pgSQL procedure with received hash as argument

-Postgres stored procedure doing:
  SELECT record by hash
  if FOUND
    DELETE temporary hash data
    UPDATE email address as verified
    return FOUND
  if NOT_FOUND
    return NOT_FOUND

-Servlet return success or fail HTML page.

As I think, with mongoDB migration, I need move some logic from pl/pgSQL procedures to java Servlet.

Is it right?

1
  • 1
    I would call this scenario way over use of stored procedures. There are no consistentcy problems by allowing this to be done client side. If the user uses another browser/window then they are aware of it and an error will be returned saying "oops that token is now invalid". This is way over use of stored procedures Commented Dec 11, 2014 at 15:23

1 Answer 1

2

Yes, you are right.

Do not store application logic in the database. There are performance limitations to running JavaScript inside of MongoDB.

http://docs.mongodb.org/manual/tutorial/store-javascript-function-on-server/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.