
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
goobs-database-plugin
Advanced tools
A flexible and extensible multi-database plugin for TypeScript projects, initially featuring MongoDB support. This plugin offers generic CRUD operations with company and user segregation, type-safe document handling, automatic metadata tracking, and built
A flexible and extensible multi-database plugin for managing generic document operations with TypeScript support. Currently featuring MongoDB integration, with plans to support additional databases in the future.
To install the plugin, run:
npm install goobs-database-plugin
or
yarn add goobs-database-plugin
.env
file in your project root with the following content:MONGODB_URI=your_mongodb_connection_string_here
.env
file in your .gitignore
to keep your credentials secure.First, import the necessary functions and types from the plugin:
import {
getFromMongo,
removeFromMongo,
updateItemInMongo,
createGenericSchema,
GenericDocument,
GenericSerializableData,
} from 'goobs-database-plugin'
Create a schema for your document using createGenericSchema
:
import { Schema } from 'mongoose'
interface MyDocument {
name: string
age: number
}
const mySchema = createGenericSchema<MyDocument>({
name: { type: String, required: true },
age: { type: Number, required: true },
})
Use getFromMongo
to retrieve data:
async function fetchData(companyId: string, userId: string) {
const result = await getFromMongo<
MyDocument,
GenericSerializableData<MyDocument>
>(companyId, userId, 'MyModel', {
filter: { age: { $gte: 18 } },
// Optional: provide cached data and a function to get updatedAt
cachedData: previouslyFetchedData,
getUpdatedAt: item => new Date(item.updatedAt),
})
console.log(result.data)
console.log('Is data stale?', result.isStale)
}
Use updateItemInMongo
to update or insert data:
async function updateData(
companyId: string,
userId: string,
itemData: Partial<MyDocument> & { _id?: string }
) {
const updatedItem = await updateItemInMongo<
MyDocument,
GenericSerializableData<MyDocument>
>(companyId, userId, 'MyModel', mySchema, itemData, data => {
// Validate required fields
if (!data.name || !data.age) {
throw new Error('Name and age are required')
}
})
console.log('Updated item:', updatedItem)
}
Use removeFromMongo
to delete data:
async function removeData(companyId: string, userId: string, itemId: string) {
const isRemoved = await removeFromMongo<MyDocument>(
companyId,
userId,
itemId,
'MyModel',
mySchema
)
console.log('Item removed:', isRemoved)
}
getFromMongo<T, S>
Retrieves data from MongoDB.
companyId
: stringuserId
: stringmongoModelName
: stringoptions
:
itemId?
: stringfilter?
: Record<string, unknown>cachedData?
: GenericSerializableDatagetUpdatedAt?
: (item: GenericSerializableDataReturns: Promise<{ data: GenericSerializableData<S>[] | GenericSerializableData<S> | null, isStale: boolean }>
updateItemInMongo<T, S>
Updates or inserts a document in MongoDB.
companyId
: stringuserId
: stringmongoModelName
: stringschema
: SchemaitemData
: Partial & { _id?: string }validateFields
: (data: Partial) => voidReturns: Promise<GenericSerializableData<S>>
removeFromMongo<T>
Removes a document from MongoDB.
companyId
: stringuserId
: stringidentifier
: stringmongoModelName
: stringschema
: Schema<GenericDocument>additionalFilter?
: Record<string, unknown>Returns: Promise<boolean>
createGenericSchema<T>
Creates a Mongoose schema with additional fields for company, user, and metadata.
schemaFields
: Record<keyof T, SchemaDefinitionProperty>Returns: Schema<GenericDocument<T>>
BaseDocument
: Extends Mongoose's Document
with additional fields.BaseSerializableData
: Serializable version of BaseDocument
.WithCompanyAndUser
: Interface for documents with company and user fields.GenericDocument<T>
: Combines a custom type T
with BaseDocument
and WithCompanyAndUser
.GenericSerializableData<T>
: Serializable version of GenericDocument<T>
.The plugin uses Winston for logging. Check the log files (generic-get.log
, generic-update.log
, generic-remove.log
, db-connection.log
) for detailed error information.
While this plugin currently supports MongoDB, it is designed with extensibility in mind. Future versions will include support for additional databases, allowing for seamless integration with various database systems.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.
FAQs
A flexible and extensible multi-database plugin for TypeScript projects, initially featuring MongoDB support. This plugin offers generic CRUD operations with company and user segregation, type-safe document handling, automatic metadata tracking, and built
The npm package goobs-database-plugin receives a total of 2 weekly downloads. As such, goobs-database-plugin popularity was classified as not popular.
We found that goobs-database-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.