awslabs / dynamodb-data-mapper-js

A schema-based data mapper for Amazon DynamoDB.
https://awslabs.github.io/dynamodb-data-mapper-js/
Apache License 2.0
817 stars 106 forks source link

Alternative to Object Binding #158

Open adamfortuno opened 5 years ago

adamfortuno commented 5 years ago

Wanting to use an ODM w/DynamoDB and Lambda sort of like Mongoose for MongoDB. I generally avoid creating subject domain objects (e.g., Patient, Course, Order, etc.) so DDM's object binding approach isn't great for me. Is there a way to create a table model, which you can use subsequently to create documents? Sort of like the way mongoose does...

const mongoose = require('mongoose');

(async () => {

        // Create the table model
    const Course = mongoose.model("Course", {
        course_id: {
            type: String
        },
        course_name: {
            name: String
        }
    });

        // Create a new document
    const csc101 = new Course({
        course_id: 101,
        course_name: "Introduction to Mongoose"
    });

    try {
        await csc101.save();
    } catch (error) {
        console.log("Shiz went bad b.", error);
    }
})();