1

Is there a simple abstraction layer that supports both DynamoDB and MongoDB, failing that a simple wrapper on top of Dynamoose and Mongoose.

I've tried building the wrapper myself but can't seem to work out how to accomplish this, I was hoping to do something along the lines of this, unfortunately it just ends up being undefined when I try to import it.

import dynamoose from 'dynamoose'
import mongoose from 'mongoose'

const name = 'MyModel'
const schema = {
  id: String
}

const isAWS = () => {
  return true
}

export default isAWS() ? dynamoose.model(name, schema) : mongoose.model(name, schema)

If needs be I could try writing a wrapper myself using typescript that just abstracts the basic CRUD functions.

DeltaByte
  • 21
  • 2
  • 4

0 Answers0