Dmitry
Dmitry

Reputation: 867

Migration from Postgres to MongoDB

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?

Upvotes: 1

Views: 365

Answers (1)

Dmitriy Sorochenkov
Dmitriy Sorochenkov

Reputation: 114

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/

Upvotes: 2

Related Questions