GithubHelp home page GithubHelp logo

oknoah / final-orm Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 0.0 23.46 MB

Now witness my Final ORM! Node ORM for ArangoDB. Moved: https://gitlab.com/NoahGray/final-orm

Home Page: https://gitlab.com/NoahGray/final-orm

JavaScript 100.00%

final-orm's People

Contributors

oknoah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

final-orm's Issues

Requesting MyModel._collection fails the first time

When doing

const collection = await MyModel._collection // returns null

it seems to always return null the first time. Running the function again will work properly. I guess it is not initialized full. Maybe a constructor is needed to fix this.

Hard Delete

Hi again!

I currently have the situation where I have a user ID and I want to delete that user from the database. I have the following two questions:

  1. To delete the user, I need to do the following:
const user = User.get(_id);
user.remove();

This will result in two database queries, right? Is there another way to do it in just one query, f.e. User.remove(_id);?

  1. When I use

Model.remove(model)

or

Model.prototype.remove()

it only changes the removed flag from false to true. Is there a way to hard delete the user from the database as well?

Thanks in advance!

Best regards,
jinxcifer

Add support for defaults

export default class User extends Model {
  static schema = {
    name: String,
    email: String,
    password: String,
    role: { $type: String, enum: ['ADMIN', 'USER'], default: 'USER' },

Also, perhaps there needs to be some consistency with the naming of options. $ before or not?

Error: getaddrinfo ENOTFOUND

When trying to connect to arangoDB with specified host (besides 'localhost'), it always return this error

Error: getaddrinfo ENOTFOUND user_name user_name:80

I already specified all information needed but it seemed override the configuration parameters I specified.

Map AQL to Argument

Hi,

I am using the following function:

User.findOne({where: {email: email, username: username}})

With this query, I get the first user which has the specified email AND username (if there is one), right? Is it also possible to specify that I want to get the first user who has the specified email OR username? If it's possible, what do I have to pass as parameter?

Thanks in advance!

Best regards,
Jinxcifer

Cannot set indexes

This code does not seem to work as intended:

static async _getCollection () {
    if (this._collection) {  // always seems to be true
      return this._collection
    }

    const db = await this._getDatabase()
    const collection = db.collection(this.name)
    try {
      await collection.create()
      await this._setIndexes(collection)
    } catch (e) {
    }
    return this._collection = collection
  }

  static async _setIndexes (collection) {
    const schema = this._getSchema()
    for (const field of schema) {
      if (!field.options.index) continue

      const path = field.path.join('.')
      const unique = field.options.unique
      await collection.createHashIndex(path, {unique})
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.