Context: Utilizing Vue to interact with cloud functions for accessing data from firestore (avoiding direct firestore queries). A function is called wherein one field returns firestore's timestamp representation (seconds, nanoseconds). Also, I'm a novice in typescript/Vue, so forgive any oversight on my part.
Here is the model class I defined:
<script lang="ts">
interface Order {
order_id: number
uid: string
create_date: Date //{ _seconds: number; _nanoseconds: number } ... from Firestore timestamp
}
export default Vue.extend({
data() {
return {
userOrderInfo: [] as Order[],
}
},
methods: {
getUserOrders() {
userOrders({ uid: this.$store.state.uid })
.then(result => {
const orderList: Order[] = JSON.parse(JSON.stringify(result.data))
const filteredOrders: Order[] = []
orderList.forEach(o => {
filteredOrders.push(o)
const tempCreateDate = new firebase.firestore.Timestamp(
o.create_date._seconds,
o.create_date._nanoseconds,
o.create_date = tempCreateDate.toDate()
}
})
I'm encountering challenges in parsing and storing the create_date value.
- The current approach of retrieving nanoseconds and seconds to recreate the Timestamp and then calling toDate() feels clunky. Is there a more elegant solution?
- VSCode displays this error, though the code runs smoothly. "Property '_seconds' does not exist on type 'Date'.Vetur(2339)" It indicates an issue with how _seconds and _nanoseconds are defined in the data() function.
Is there a more efficient way to define and fetch the date?
- The warning for o.create_date = tempCreateDate.toDate() states: Identifier 'create_date' is not in camel case.eslint@typescript-eslint/camelcase The cloud function returns create_date in this format, so changing it to camel case isn't feasible.
Any potential solutions to address this warning?