Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coder committed Feb 13, 2023
1 parent 1d2c924 commit 6eb6ed2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions models/pair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const mongoose = require('mongoose')

const tokenSchema = new mongoose.Schema({
chanId: Number,
decimals: Number,
symbol: String,
name: String,
isNative: Boolean,
isToken: Boolean,
address: String,
logoURI: String
})

const observationsDataSchema = new mongoose.Schema({
timestamp: Date,
price: Number,
})

const observationsSchema = new mongoose.Schema({
name: String,
seconds: Number,
observationsData: [observationsDataSchema],
})

const pairSchema = new mongoose.Schema({
symbol: String,
baseToken: tokenSchema,
quoteToken: tokenSchema,
poolAddress: String,
poolFee: String,
arrayTypes: [String],
extraMinutesData: Number,
observations: [observationsSchema],
})

pairSchema.set('toJSON', {
transform: (document, returnedObject) => {
returnedObject.id = returnedObject._id.toString()
delete returnedObject._id
delete returnedObject.__v
}
})

module.exports = mongoose.model('Pair', pairSchema)

0 comments on commit 6eb6ed2

Please sign in to comment.