What is dynamoose?
Dynamoose is a modeling tool for Amazon's DynamoDB, inspired by Mongoose. It provides a simple and easy-to-use API for defining schemas, models, and performing CRUD operations on DynamoDB tables.
What are dynamoose's main functionalities?
Schema Definition
Dynamoose allows you to define schemas for your DynamoDB tables. This schema definition helps in structuring the data and enforcing data types.
const dynamoose = require('dynamoose');
const UserSchema = new dynamoose.Schema({
id: String,
name: String,
age: Number
});
Model Creation
Once you have defined a schema, you can create a model. This model will be used to interact with the DynamoDB table.
const User = dynamoose.model('User', UserSchema);
CRUD Operations
Dynamoose provides methods for performing CRUD operations. You can create, read, update, and delete items in your DynamoDB table using the model.
const newUser = new User({
id: '1',
name: 'John Doe',
age: 30
});
newUser.save();
User.get('1').then(user => console.log(user));
User.update({ id: '1' }, { age: 31 });
User.delete('1');
Query and Scan
Dynamoose supports querying and scanning the DynamoDB table. You can use various conditions to filter the data.
User.query('name').eq('John Doe').exec().then(users => console.log(users));
User.scan('age').gt(25).exec().then(users => console.log(users));
Other packages similar to dynamoose
aws-sdk
The AWS SDK for JavaScript provides direct access to DynamoDB and other AWS services. It is more low-level compared to Dynamoose and requires more boilerplate code for operations.
vogels
Vogels is another DynamoDB modeling tool inspired by Mongoose. It offers similar functionalities to Dynamoose but is less actively maintained.
Dynamoose
Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by Mongoose)
Getting Started
Installation
$ npm install dynamoose
Example
Set AWS configurations in enviroment varable:
export AWS_ACCESS_KEY_ID="Your AWS Access Key ID"
export AWS_SECRET_ACCESS_KEY="Your AWS Secret Access Key"
export AWS_REGION="us-east-1"
Here's a simple example:
var dynamoose = require('dynamoose');
var Cat = dynamoose.model('Cat', { id: Number, name: String });
var garfield = new Cat({id: 666, name: 'Garfield'});
garfield.save();
Cat.get(666)
.then(function (badCat) {
console.log('Never trust a smiling cat. - ' + badCat.name);
});
API Docs
The documentation can be found at https://dynamoosejs.com/api. You can also find additional examples at https://dynamoosejs.com/examples.
Help Wanted!
Help improve Dynamoose. I need all the help I can get to improve test coverage and the documentation. If you would like to help please look at the /test
folder to add tests to the project along with /docs/_docs
and /docs/_examples
folders to help write better documentation and examples for Dynamoose. You can create a PR (pull request) to get your changes merged in. Thank you very much!!
ChangeLog
The Dynamoose ChangeLog can be found in the CHANGELOG.md file.
Roadmap
The Dynamoose Roadmap can be found in the ROADMAP.md file. Help is always appreciated on these items. If you are able to help submit a PR so we can review and improve Dynamoose!
Version 1.0.0
Dynamoose version 1.0.0 is here. This is a massive release, and will also be the first official breaking update to Dynamoose. You can view the details about the release below.
This version officially removes support for Node.js versions below 8.0. Versions below 8.0 might work, but we do not make guarantees. Even if Node.js versions below 8.0 work with Dynamoose 1.0+ we might add features that break support for older Node.js versions without a SEMVER major version release.
The one major thing about the release notes below that is a bit confusing is the fact that ES6/Future Changes
are in the Breaking changes
section. That section is directly related to Requiring Node.js version 8.0 and higher
. Therefor although the breaking change is technically the fact that Node.js versions less than 8.0 won't be supported, they are directly related, therefor they are both in the Breaking changes
section. In future 1.x we might add more ES6/Future Changes, but those will not be considered breaking changes due to the fact that it will only break if you are running on a Node.js version less than version 8.0.
Please comment or contact me if you have any questions about this release.
🚨 Breaking changes 🚨
Major New Features
General
Bug Fixes
Documentation
Other