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?
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/
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句