const { v4: uuidv4 } = require("uuid");

// 内存存储：record_id → { dream, interpretation, userId, createdAt }
const records = new Map();

module.exports = {
  saveRecord(userId, dream, interpretation) {
    const id = uuidv4();
    records.set(id, {
      id,
      userId,
      dream,
      interpretation,
      createdAt: new Date().toISOString(),
    });
    return id;
  },

  getRecord(id) {
    return records.get(id) || null;
  },
};
